Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide NavigationBar for one ViewController in Storyboard

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:

enter image description here

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!

like image 874
Siriss Avatar asked Oct 31 '12 21:10

Siriss


People also ask

How do I hide navigation bar in Swift storyboard?

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.

How do I hide Navigationitem?

Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.

How do I hide the navigation bar in one screen in Swift?

How To Hide Navigation Bar In Swift. To hide the navigation bar in Swift, you'll need to add code to two methods: viewWillAppear and viewWillDisappear . That's it to hide the navigation bar in your view controller.


1 Answers

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];
}
like image 187
user427969 Avatar answered Sep 19 '22 03:09

user427969