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

scrollVerticallyToOffset doesn't work #4

Open
yingogobot opened this issue Feb 1, 2014 · 4 comments
Open

scrollVerticallyToOffset doesn't work #4

yingogobot opened this issue Feb 1, 2014 · 4 comments
Labels

Comments

@yingogobot
Copy link

Hello,

I was recently using your scroll view, i like it very much, but there is one thing i would like to know that scrollVerticallyToOffset seems like not working.

And i was also tried to use something like
[_glassScrollView.foregroundScrollView setContentOffset:CGPointMake(0, 200) animated:YES];

doesn't work either, would you mind take a look at it, i don't know if that's a bug or not.

Thanks,

YinBot

@yingogobot
Copy link
Author

I think i found the issue, when we call
[_glassScrollView scrollVerticallyToOffset: 300];

it will trigger the view controller to call - (void)viewWillLayoutSubviews again.

And in your example, you have
[_glassScrollView setTopLayoutGuideLength:[self.topLayoutGuide length]];
in the viewWillLayoutSubviews, setTopLayoutGuideLength will change the content size of _foregroundScrollView, which cause the setContentOffset is ignored.

Maybe we want to put [_glassScrollView setTopLayoutGuideLength:[self.topLayoutGuide length]];
in view did load.

@BTLibrary
Copy link
Owner

Thanks for reporting a bug. I don't quite understand the problem. Is that in my example? If not, would you mind provide a snippet of what you had? I am uploading a newer version of this with better example. It might fix the bug but let me know. Thanks!

@yingogobot
Copy link
Author

Hi it's not in your example, but i found in the header file, there is a method call

  • (void)scrollVerticallyToOffset:(CGFloat)offsetY;

I was trying to use that method
such as [_glassScrollView scrollVerticallyToOffset: 300];
but unfortunately that methods doesn't do anything.

@BTLibrary
Copy link
Owner

To my knowledge, calling scrollVerticallyToOffset should not trigger viewWillLayoutSubviews. If you look into BTGlassScrollView.m you will see it only offset the scrollView. That alone cannot cause viewWillLayoutSubviews. Please confirm that your code do not have anything else to do with calling viewWillLayoutSubviews. In my original example, I use it in the scrollViewDidScroll delegate method and it works really well.

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

No branches or pull requests

2 participants