Reputation: 12351
Can anyone tell me how to hide the navigation bar in my storyboard. My code below is working fine when running in the simulator but it still appears in my storyboard which is really annoying me as it's messing around with the placement of my images. Can anyone help?
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
Upvotes: 36
Views: 32979
Reputation:
Follow these step:
1: Go to storyboard
2: Select navigation controller
3: Goto Attribute inspector
4: Under navigation controller bar visibility **Uncheck the Shows navigation Bar***
Upvotes: 6
Reputation: 2595
Solution for the same using Swift 3:
Step 1. Using attribute inspector hide Navigation Bar from Storyboard:
Step 2. Add the following code to your ViewController
:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Hide the navigation bar on the this view controller
self.navigationController?.setNavigationBarHidden(true, animated: animated)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Show the navigation bar on other view controllers
self.navigationController?.setNavigationBarHidden(false, animated: animated)
}
Upvotes: 8
Reputation: 343
You have to click the actual navigation controller, not the view controller. On the view controller the navigation drop down doesn't show up, but you can still achieve this by selecting Top Bar: none in Simulated Metrics.
Upvotes: 12
Reputation: 4251
Click on the controller that has the top bar navigate to the properties bar on the right hand side of Xcode. There is a drop down labeled Top Bar (as shown above) change this drop down to none.
Upvotes: 70
Reputation: 14427
In the Storyboard view, just select the NavigationController scene and UNCHECK Shows Navigation Bar (Attributes Inspector)
Upvotes: 10