UIScrollView's origin changes after popping back to the UIViewController
In iOS 7/8/9 simple self.automaticallyAdjustsScrollViewInsets = NO;
solved the problem in my case.
Try this in viewWillAppear of the view controller you pop back into:
self.scrollView.contentOffset = CGPointMake(0, 0);
Edit: When also adding Peter's code you get the best results with:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
self.scrollView.contentOffset = CGPointMake(0, 0);
}
plus
- (void)viewWillDisappear:(BOOL)animated {
self.recentContentOffset = self.scrollView.contentOffset;
[super viewWillDisappear:animated];
}
and
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.scrollView.contentOffset = CGPointMake(0, self.recentContentOffset.y);
}
You return to the original scroll position, have no visual side-effect and the scroll view itself is correctly positioned in its superview (which was a problem) after coming back.