I have the code below that hides and shows the navigational bar. It is hidden when the first view loads and then hidden when the "children" get called. Trouble is that I cannot find the event/action to trigger it to hide again when they get back to the root view….
I have a "test" button on the root page that manually does the action but it is not pretty and I want it to be automatic.
-(void)hideBar
{
self.navController.navigationBarHidden = YES;
}
-(void)showBar
{
self.navController.navigationBarHidden = NO;
}
Best Answer
The nicest solution I have found is to do the following in the first view controller.
Objective-C
Swift
This will cause the navigation bar to animate in from the left (together with the next view) when you push the next
UIViewController
on the stack, and animate away to the left (together with the old view), when you press the back button on theUINavigationBar
.Please note also that these are not delegate methods, you are overriding
UIViewController
's implementation of these methods, and according to the documentation you must call the super's implementation somewhere in your implementation.