Mike Buss Mike Buss - 1 year ago 160
iOS Question

self.navigationController.navigationBar setHidden:NO not working when view controllers are swapped out

I'm experiencing some weird behavior with hiding and showing the UINavigationBar.

In my

method I'm calling this:

self.navigationController.navigationBar.hidden = YES;

and when the user presses a button I'm calling this:

self.navigationController.navigationBar.hidden = NO;

and then swapping out the current view controller using the viewControllers property of a custom UINavigationController.

This works fine, but if I try to show the navigationBar using the same line in the
method, it doesn't work. The navigationBar is still hidden.

I'm able to show/hide the status bar in
using the following method:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

but showing/hiding the UINavigationBar doesn't work!

EDIT: Also,
after I try to show the bar in
but the bar is still hidden.

Any help would be greatly appreciated. Thank you!

Answer Source

Because you’ve already swapped the current view controller out of the stack, self.navigationController is probably nil when viewWillDisappear is called.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download