I have a UIScrollView added and positioned via Interface Builder, as part of a view controller on a navigation controller stack. When I push a new view controller onto the stack, then pop that new view controller, the UIScrollView in the original view has drifted upwards by exactly 52 pixels.
This ONLY happens on the device, and not the Simulator.
Any ideas what might be causing this? I can fix it retroactively with calls to re-position in the viewWillAppear/viewWillAppear, but for some reason on a very few occasions even this doesn’t work, so I’d really like to fix the root cause. Thanks!
Note in response to comments: I’m hiding the navigation bar in the pushed view controller, but not the original view controller. Also note that there are several other UIView elements on the original view controller, but it’s only the UIScrollView which is moving out of position.
Update: not hiding the navbar in the pushed view controller has no impact on the UIScrollView problem – but thanks for the suggestion, commenters.
Fix: if the navigation bar is being hidden on a view controller, and you don’t want any subviews (which you added via Interface Builder) automatically re-positioning in unexpected ways, make sure the struts on the subviews are set to be fixed.