Reputation: 3767
I have found many posts, but still no solution. I am trying to hide a NavigationBar on the initial UIViewController
, but i want to still show it on the second UIViewController
. Here is my storyboard:
When I turn off the Inferred Top Bar for my Main View Controller, it disappears in Storyboard, but it still shows when I run the app. When I do the same in to the NavigationBar in NavController, it disappears for all three (because they all inherit the no Nav Bar).
I want to show the NavBar in ScrollViewV View Controller, but have it hidden in MainViewController
.
All Controllers have the corresponding .h or .m files, but I am confused on how to do this programmatically. Let me know if you need to see anything else. Thank you much!
Upvotes: 13
Views: 16952
Reputation: 1466
Anyone wanting to know how to do this in Swift?
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.navigationController?.navigationBar.hidden = true
}
Upvotes: 0
Reputation: 5990
If you want to keep things in the Storyboard than edit the User Defined Attributes and
set navigationController.navigationBarHidden
as a Boolean checked.
Upvotes: 2
Reputation: 3886
In your mainViewController, you can do following:
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
You might want to show the Navigation bar when hiding this ViewController, for that do the following:
- (void)viewDidDisappear: (BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewDidDisappear:animated];
}
Upvotes: 43
Reputation: 1585
I noticed that you also need to add the following to the controller that you do want the navigation to appear.
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillAppear:animated];
Upvotes: 0