I have a Scrollview, it's properties are set in viewDidAppear. Now when I get to the Scrollview first time there isn't any problem. However I have buttons that are assigned to UINavigationController. So when I press into one of them UINavigationController opens up, when I close the navigation controller, ScrollView does not restore properly. It basically aligns the centre of the screen as previously pressed button location. So if I try to scroll up it does not.
I have tried using this in my viewDidAppear:
scrollView.center = CGPointMake(scrollView.contentOffset.x, scrollView.contentOffset.y);
Which did not quite work. How can I solve this? I am using iOS6.1
Actually I found the answer here:
UIScrollview Autolayout Issue
The exact code that I used is:
previousPoint
is nothing but a CGPoint variable declared on the implementation.I've had this problem before too. This answer shows how to overcome this issue.
Basically, you need to set the scrollview's
contentOffset
appropriately inviewWillAppear:
andviewDidDisappear:
.EDIT: Here's another related question that you might find useful, UIScrollview Autolayout Issue.