Craig Garnham
Craig Garnham

Reputation: 93

UIScrollView top position changing when switching view

I have a UIScrollView on a UITabBar app. If the scrollview is left scrolled down when i change to a different view when changing back to it the position it was left in becomes the new top and i cannot scroll back up and there is whitespace added to the bottom. How can i stop this from happening?

I have written a temporary fix by setting ViewWillDisappear to scroll to top.

Upvotes: 0

Views: 201

Answers (1)

marce
marce

Reputation: 13

I was having the same problem and I also fixed it with viewWillDisappear. Here is the code I used.

-(void)viewWillDisappear:(BOOL)animated{

[scroller2 scrollRectToVisible:CGRectMake(0,0,320, 1297) animated:NO];

[super viewWillDisappear:animated];

Upvotes: 1

Related Questions