Full Screen UIScrollView not working Correctly

cocoa-touch, ios, iphone, uiscrollview

Solution

I spoke with DTS about this and they said this is the designed behavior and recommended to attach the `UIScrollView` to a parent `UIView`.

Problem

I have an application like the photos app where the main view is a `UIScrollView` which takes up the full size of the screen. Also, like the photos app, when the user taps the screen there are translucent navigation, status, and tool bars which reappear / disappear. I am having a problem setting the `UIViewControllers` main view as a `UIScrollView` and having it take up the full length of the screen. The problem is that when the navigation and status bars are shown, the `UIScrollView` gets pushed down by the height of the navigation and status bars (it doesn't go underneath them like it's suppose to). When the user taps the screen and the navigation / status bars disappear, then it resets itself to take up the full length of the screen like it's suppose to. A simple work around of setting the main view as a `UIView` and attaching a `UIScrollView` on top of it works. However, I'd like to try and get this to work without any workarounds (ie adjusting the `UIScrollViews contentInset`, etc) because in theory it should work. Below is the code I'm implementing: ``` - (void)loadView { self.wantsFullScreenLayout = YES; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame: CGRectMake(0,0,320,480)]; scrollView.contentSize = CGSizeMake(320, 480); scrollView.scrollEnabled = NO; scrollView.contentOffset = CGPointZero; scrollView.bounces = NO; self.view = scrollView; [scrollView release]; } - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBar.translucent = YES; [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent animated: NO]; self.navigationController.toolbarHidden = NO; self.navigationController.toolbar.barStyle = UIBarStyleBlack; self.navigationController.toolbar.translucent = YES; [self startTimer]; } - (void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; self.navigationController.navigationBar.translucent = NO; [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: NO]; [self cancelTimer]; } ``` UPDATE: I've noticed it's the `contentOffset` and `contentInset` that are changing, not the `scrollViews` frame. When the bars have disappeared and the `UIScrollView` is the full size of the screen (as it should be), the `contentOffset` and `contentInset` are as follows: ``` Content Offset: {0, -20} Content Inset: {20, 0, 44, 0} ``` When the bars are visible and the `UIScrollView` is pushed down, the `contentOffset` and `contentInset` are as follows: ``` Content Offset: {0, -64} Content Inset: {64, 0, 44, 0} ```

Original source