I have a UIScrollView whose content offset resets itself all the time for some random reason. Has anyone ever encountered this issue? I had the content offset to 100 and then it resets back scrolling to the top. Any way to prevent this?
So here's the code/hack that I did to make it work in setting the contentOffset:
[self.currentViewController_ performSelector:@selector(scrollToOffset:) withObject:nil afterDelay:0.1];
and in my currentViewController class I have
-(void)scrollToOffset: (CGFloat) yOffset
{
[[self.webView_ defaultScrollView] setContentOffset:CGPointMake(0, -44) animated:YES];
}
I had a similiar problem. In my case, the problem was that I set the content size of the scrollview in viewDidLayoutSubviews. When I tried to scroll the view back programatically, viewDidLayoutSubviews was called and this caused a reset of the content size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With