Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with IndexView #165

Open
kenhcwoo opened this issue Apr 3, 2013 · 3 comments
Open

Bug with IndexView #165

kenhcwoo opened this issue Apr 3, 2013 · 3 comments

Comments

@kenhcwoo
Copy link

kenhcwoo commented Apr 3, 2013

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?

@kolinkrewinkel
Copy link
Owner

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.

@kenhcwoo
Copy link
Author

kenhcwoo commented Apr 3, 2013

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
    };
}

@kolinkrewinkel
Copy link
Owner

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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants