I just noted that if I put a UIScrollView as the root view of a UIViewController:
- (void)loadView
{
self.view = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
}
I get a lot of behavior for free: The scrollView sets it's contentInset
and scrollIndicatorInsets
automatically if the status bar, navigation bar, or toolbar are present and translucent, and updates the properties if any navigation layouts change:
[self.navigationController setNavigationBarHidden:YES animated:YES];
Unfortunately the scroll view also changes it's contentOffset
automatically when changing the contentsInset
, so the content goes up when the navigation bar disappears and down when the navigation bar appears.
I like a lot of this free behavior, but I would like for my content to stay still when the navigation bar comes and goes, and I can't find where to avoid the change in contentOffset
.
Edit:
After some stack traces, I discovered a method that is being called every time the offset is automatically adjusted: [UIScrollView(Static) _adjustContentOffsetIfNecessary]
; but since I can't find any documentation on this method, I'm at a loss.