3

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

aslı
  • 8,740
  • 10
  • 59
  • 80

2 Answers2

14

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];
}
Community
  • 1
  • 1
aslı
  • 8,740
  • 10
  • 59
  • 80
3

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

HoanNguyen
  • 405
  • 2
  • 12
  • Hm... I have created a project to testing, it worked well. So I think your code somewhere affected this view. – HoanNguyen Mar 17 '14 at 04:16
  • Hey Hoan, check my answer below. I could finally figure it out **phew**! Thanks for your answer! – aslı Mar 20 '14 at 05:17