UIScrollView's origin changes after popping back to the UIViewController

cocoa-touch, ios, storyboard, uiscrollview

Solution

Actually, I put that line of code in `viewDidDisappear`, and so that it remembers the offset when the view reappears, I added this line before it

 self.contentOffset = self.scrollView.contentOffset;

as well as

 - (void)viewDidLayoutSubviews { 
       self.scrollView.contentOffset = self.contentOffset; 
 }

Problem

I have a `UIViewController` subclass as a scene in the storyboard that contains a `UIScrollView` containing various subviews. One of the subviews is a `UIButton` which segues into another scene `UIViewController` subclass. When I come back from the view (pop the `UIViewController` off the navigation controller stack), I find that the scroll view's origin has somehow changed, although the `contentsize` and `contentoffset` seem correct. What's also interesting is that the app has a tab bar, and when I tab away and back to that view, the scroll view is set back correctly with offset at (0, 0). There is basically no code involved in this process, as it's pretty much all in the storyboard. As I am fairly new to using the storyboard, I figure I'm doing something wrong, although I don't know what. Any ideas as to what that may be? Perhaps sizing issues or constraints?

Original source

Related problems