There are a couple of things.
- You must access the navigation controller that your view controller represents using
self.navigationController . Your code snippet creates a new UINavigationController; hiding this bar, you wonโt get anything. - Instead of hiding the navigation bar in
viewDidLoad , you should hide it in viewWillAppear: You can hide the navigation bar in viewDidLoad , and the navigation bar will be hidden when the view is initially presented, but if you want to click another view that displayed the navigation bar and click the back button, the navigation bar will remain visible.
Your viewWillAppear: should look something like this:
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:animated]; }
And the viewWillAppear: methods viewWillAppear: in other view controllers that you click on this navigation controller, should show or hide the navigation bar accordingly.
source share