Reputation: 6284
I have a universal app, and on the iPad version I'm using UISplitViewController
to create an interface similar to the Mail app.
I was having trouble pushing new Detail views, so I decided to use a UINavigationController
so I could just push and pop views as needed. However, I do not want to use the navigation view or a toolbar. But no matter what I do, I can't hide the navigation bar.
I've tried unchecking "Shows Navigation Bar" in IB, and I've also tried setting:
[self.navigationController setNavigationBarHidden:YES];
in the viewDidLoad
/viewDidAppear
/viewWillAppear
. I've also tried it in each of the views that will be pushed. Nothing works.
Is there something I'm missing here? Is it possible to have a UINavigationController
without a toolbar or navigation bar?
Upvotes: 122
Views: 89066
Reputation: 2317
You should be able to do the following:
self.navigationController.navigationBar.isHidden = true //Swift 5
where self.navigationController is (obviously) an instance of UINavigationController. Seems to work for me, but I only briefly tested it before posting this.
Upvotes: 201
Reputation: 6213
All these answers still leave a space at the top for the status bar - add this line to remove that as well:
navController.navigationBar.isHidden = true
navController.accessibilityFrame = CGRect.zero
Upvotes: 1
Reputation: 171
Swift 4
I hide it in viewWillAppear
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.isNavigationBarHidden = true;
}
Then you can put it back when you push a segue (if you want to have the back button on the next view)
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
self.navigationController?.isNavigationBarHidden = false;
}
Upvotes: 8
Reputation: 7114
self.navigationController.isNavigationBarHidden = true
or
self.navigationController.navigationBar.isHidden = true
Note: I didn't see a difference between these two approaches testing on iOS 10.
Upvotes: 3
Reputation: 11073
If you want no navigation bar, and you want the content to be adjusted up to where the navigation bar normally would be, you should use
self.navigationController.navigationBarHidden = YES;
This gives you a result like this:
Whereas self.navigationController.navigationBar.hidden = YES;
gives you a space where the navigationBar should be. Like this:
Upvotes: 40
Reputation: 5831
In Xcode 4.3.2:
Under the Navigation Controller category you have two check boxes:
[] Shows Navigation Bar
[] Shows Toolbar
Worked for me...
Upvotes: 40