garethdn
garethdn

Reputation: 12351

Hide navigation bar in storyboard

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

Answers (6)

Ankur Lahiry
Ankur Lahiry

Reputation: 2315

For specific ViewController, set the topbar as none

enter image description here

Upvotes: 1

user5180348
user5180348

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***

enter image description here

Upvotes: 6

Codetard
Codetard

Reputation: 2595

Solution for the same using Swift 3:

Step 1. Using attribute inspector hide Navigation Bar from Storyboard: enter image description here

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

Ford Davis
Ford Davis

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.

Top Bar: None

Upvotes: 12

shoughton123
shoughton123

Reputation: 4251

enter image description here

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

LJ Wilson
LJ Wilson

Reputation: 14427

In the Storyboard view, just select the NavigationController scene and UNCHECK Shows Navigation Bar (Attributes Inspector)

Upvotes: 10

Related Questions