Hide the navigation bar in the root mode of the UINavigationViewController, but show it in others

I'm starting iOS development, and the name pretty much talks about it.

I have a UINavigationController; I would like it to not show the navigation bar if the user is looking in the root view, but showing the navigation bar in other views.

Is there an elegant way to do this?

+4
source share
2 answers

Use this line of code on all your view controllers [navigationController setNavigationBarHidden: YES animated:YES]; If animation is not needed, you can make animated:NO and add this code to viewDidLoad , otherwise put it viewWillAppear or viewDidAppear

+12
source

In the storyboard, select the root mode (highlighted in blue), then go to the property editor (on the right), show Attributes , and one of the parameters must be in order to hide it (by default it is assumed ).

-1
source

Source: https://habr.com/ru/post/1387806/


All Articles