Search code examples
iosobjective-cuinavigationcontrolleruinavigationbaruistoryboardsegue

Hide navigation bar, but when I transition to the previous view (popped) it shows the old back button temporarily. Why?


I have view controllers in a navigation controller (root: RootViewController, second: ReadingViewController), but in the second view controller I want to disable the navigation bar for a UIToolBar (as I don't need the title and want more buttons, like in iBooks or the Facebook app). Problem is, when I hide the navigation bar in the second view, it appears randomly for a second again when I pop the view controller (go back).

When I pop the view controller the back button appears for a second:

enter image description here

In the second view controller I hide the nav bar in viewWillAppear::

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

Also in the second view controller, I restore the nav bar in viewWillDisappear::

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    // ... other stuff

    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

I'm wondering how I combat this issue so that the view controllers transition seamlessly.


Solution

  • Hey why don't you use navigation bar as a UIToolbar.

    Instead Of hiding UINavigation you can mimic navigation controller to UITootlbar by adding buttons to it.

    hiding unhiding UINavigation would be complex.

    I am Uploaded the dropbox link.