Black area with interactivePopGestureRecognizer when popping a view controller with visible nav bar to a one with hidden nav bar

StackOverflow https://stackoverflow.com/questions/22442185

Question

I have this ViewController #1 which is the root view controller of a navigation controller and has

self.navigationController.navigationBarHidden = YES;

ViewController #1 tells its navigation controller to push ViewController #2, which has

self.navigationController.navigationBarHidden = NO;

When I want to go back from ViewController #2 to ViewController #1 by swiping from the left side of the screen, I see my views as the screenshot I attached here. This is captured as I move my finger to the right, so as I keep swiping to the right, the black area on the top right gets smaller and smaller until ViewController #1 covers all the screen area.

I'm guessing that this is caused by the hidden/visible navigation bar difference between the two view controllers.

I'd like to learn if it's possible to get rid of this black area.

enter image description here

Était-ce utile?

La solution

As discussed with HoanNguyen, I had put my code to hide/show the navigation bar on viewWillAppear/Disappear but finally I figured out that the trick was to set the values animated. Weird, but this solved my problem and the black area is now gone:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:self.shouldHideNavBar animated:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:!self.shouldHideNavBar animated:animated];
}

Autres conseils

You should put your code set hidden/shown navigation in viewWillAppear or viewDidAppear.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top