KKGridView icon indicating copy to clipboard operation
KKGridView copied to clipboard

Bug with IndexView

Open kenhcwoo opened this issue 11 years ago • 3 comments

I'm using a grid with an IndexView. I'm adding the grid as a subview into a view controller, and setting autoresizing masks to be FlexibleHeight | FlexibleWidth and I'm noticing two issues.

One is if I add the subview and call reloadData, the indexView doesn't show up. It'll show up once I do a rotation and will also show again when I rotate back.

The other is if I've scrolled down a bit, and I do a rotation, the indexView will be shifted up so that only the bottom portion is showing (related to how much down I've scrolled). If I scroll after the indexViews get messed up, then it'll pop back into position.

Any ideas?

kenhcwoo avatar Apr 03 '13 02:04 kenhcwoo

I've never used an index view in any situation, sorry. Only thing I can recommend is logging and messing with the frames in layoutSubviews to see what's causing the issue (be it incorrect sizing, alignment, or autoresizing masks).

Sent from my iPhone

On Apr 2, 2013, at 19:53, Ken Woo [email protected] wrote:

I'm using a grid with an IndexView. I'm adding the grid as a subview into a view controller, and setting autoresizing masks to be FlexibleHeight | FlexibleWidth and I'm noticing two issues.

One is if I add the subview and call reloadData, the indexView doesn't show up. It'll show up once I do a rotation and will also show again when I rotate back.

The other is if I've scrolled down a bit, and I do a rotation, the indexView will be shifted up so that only the bottom portion is showing (related to how much down I've scrolled). If I scroll after the indexViews get messed up, then it'll pop back into position.

Any ideas?

— Reply to this email directly or view it on GitHub.

kolinkrewinkel avatar Apr 03 '13 04:04 kolinkrewinkel

Okay, I've fixed it. Didn't have time earlier to really dive into it. Basically, when the indexView was getting added back to the scrollView, it would get docked at the top. I just changed the KKGridViewIndexView.m file so that when we are moving to superview, if the class is a scrollview, we dock it to the contentOffset instead.

- (void)willMoveToSuperview:(UIView *)newSuperview {
    CGFloat newY = 0;
    if ([newSuperview isKindOfClass:[UIScrollView class]])
    {
        UIScrollView *newScrollView = (UIScrollView*)newSuperview;
        newY = newScrollView.contentOffset.y;
    }

    self.frame = (CGRect) {
        .origin.x = newSuperview.bounds.size.width - self.frame.size.width,
        .origin.y = newY,
        .size.width = self.frame.size.width,
        .size.height = newSuperview.bounds.size.height
    };
}

kenhcwoo avatar Apr 03 '13 15:04 kenhcwoo

Cool, glad you got it worked out. Going to leave this open so that anyone passing by can find it more easily. I think that's a good idea. Maybe not. I'll leave it up to you. :)

kolinkrewinkel avatar Apr 04 '13 05:04 kolinkrewinkel