36

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];
}
2
  • 1
    For everyone trying to figure out how to hide the navbar for a particular view controller from the storyboard...this is not possible. BUT, there is a good reason for this. The expected way is to first simply hide/show the navbar programmatically (something like self.navigationController?.setNavigationBarHidden(true, animated: animated), then in your storyboard, adjust the Simulated Metrics > Top Bar for each individual view controller so that its appearance reflects what currently happens from your code...
    – Eric
    Commented May 29, 2021 at 19:58
  • ...Because the purpose of those Simulated Metrics is so you can get an idea of what your view will look like based on the code whose effects you can't "see" yet.
    – Eric
    Commented May 29, 2021 at 19:58

6 Answers 6

70

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.

5
  • I think this is the same answer the first.
    – LJ Wilson
    Commented May 16, 2012 at 14:22
  • It was added while i was typing Commented May 16, 2012 at 14:26
  • 12
    What if i want it per view controller? Commented Nov 29, 2013 at 20:28
  • 1
    Is anyone successful in per view controller navigation hiding and showing.
    – Imran
    Commented Aug 12, 2014 at 12:42
  • @VanDuTran See my comment on OPs original question (above).
    – Eric
    Commented May 29, 2021 at 19:56
12

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

1
  • 1
    Then it isn't for an individual view controller.
    – jowie
    Commented Apr 28, 2017 at 8:56
10

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

1
  • 6
    this applies to all of its children though - wont work if you only want to hide one Commented Nov 18, 2015 at 22:39
8

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)
}
5
  • This is just the swift 3 equivalent of what the OP has shown. This does not hide the navigation bar in the storyboard. It does. however, hide the navigation bar when running the app. Commented Aug 6, 2018 at 8:48
  • @Tim that's what it is supposedly do.
    – Codetard
    Commented Aug 6, 2018 at 11:26
  • It is not what the OP asked. Commented Aug 6, 2018 at 13:17
  • @Tim you might want to read the question again. He mentioned that navbar is still appearing in storyboard, that he doesn’t want.
    – Codetard
    Commented Aug 6, 2018 at 13:20
  • 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** I have read the question. Despite it being 6 years old. The OP asked how to hide the navbar within the storyboard. Commented Aug 6, 2018 at 13:28
6
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

1

For specific ViewController, set the topbar as none

enter image description here

1
  • This answers the OPs question, but if you're scrolling through and trying to find the answer to how to hide the nav bar for a particular view controller FROM the storyboard (not just while viewing the storyboard), unfortunately this is not possible. See my comment to the OPs original question (at the top) for why this is the case.
    – Eric
    Commented May 29, 2021 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.