Fullscreen UIScrollView not working correctly

I have an application, such as a photo application, where the main view is UIScrollViewthat takes up the full screen size. In addition, like the photo application, when the user clicks on the screen, transparent navigation, status and toolbars appear, which again appear / disappear.

I had a problem with setting up the main view UIViewControllersas UIScrollViewwell as its coverage along the entire length of the screen. The problem is that when the UIScrollViewnavigation and status bars are displayed, it gets a push in the height of the navigation and status bars (it does not go under them, as it is supposed to). When the user deletes the screen and the navigation / status lines disappear, he is reset to occupy the entire length of the screen, as expected.

Simple work on setting up the main view in the view UIViewand joining it UIScrollViewworks. However, I would like to try to get this to work without any workarounds (e.g. setup UIScrollViews contentInset, etc.), because theoretically this should work.

Below is the code that I am 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];
}

: , contentOffset contentInset, scrollViews. , UIScrollView - ( ), contentOffset contentInset :

Content Offset: {0, -20}
Content Inset: {20, 0, 44, 0}

UIScrollView , contentOffset contentInset :

Content Offset: {0, -64}
Content Inset: {64, 0, 44, 0}
+5
3

DTS , , UIScrollView UIView.

+3

iOS7 Apple UI: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/AppearanceCustomization.html

, UIViewController automaticallyAdjustsScrollViewInsets. , UIScrollView , .

+5

Try to install:

self.view.frame = CGRectMake(0.f, -44.f, 320.f 480.f);

It may not be the size you want, but you can adjust it ...

-1
source

All Articles