UIScrollView goes under the navigation and status bar

I have a view that contains scrollView. When the view appears, the image is displayed in full screen (320x480), hiding the status and navigation bar. When I click on the screens, the status and navigation bar appear on the screen. But this thing shifts the UIScrollView under the navigation bar. I want the status and navigation bar to appear on top of my scroll view.

How this happens in the photo app. When you click on the status icon and the navigation bar is displayed above the scrollView.

Below is how I position the view.


//What I have done in viewDidLoad
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
self.wantsFullScreenLayout = YES;
scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view = scrollView;

The following is what I do when a single click is detected


- (void)tapDetectingImageView:(TapDetectingImageView *)view             gotSingleTapAtPoint:(CGPoint)tapPoint {
    // single tap hide/unhide the status and nav bar
    NSLog(@"got a single tap");
    if (self.navigationController.navigationBarHidden == NO)
    {

        [self.navigationController setNavigationBarHidden:YES animated:NO];
        [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
    }
    else
    {
        [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
        [self.navigationController setNavigationBarHidden:NO animated:NO];
    }
}

Just a pointer for you guys if I use

[self.view addSubview:scrollView];
I do not see this problem. But that will ruin my terrain orientation code.

Anyone who can shed light on what I might have done wrong will be a great help!

+3
source share
2 answers

I found a solution myself. In my tap detection method still fn, I add the line below to the last.

scrollView.contentOffset = CGPointMake(parentScrollView.contentOffset.x,0);

Not sure if this is the right approach. But if someone can offer a better approach - more than welcome!

+1
source

, , UIScrollView. , UIView, .

, , autoresizingMask , . .

+3

Source: https://habr.com/ru/post/1713733/


All Articles