Unable to hide navigation bar in xcode

I made a simple application using the storyboard editor in xcode 4.6.3. The first view is a navigation controller with some simple buttons for navigation. This, by default, adds a navigation bar to the top of each new view that I create when I connect buttons to each of my pages.

However, I want the first page (the landing page I would call it to) to not have a top bar. I follow the instructions here on how to disable the top navigation bar in storyboard mode. However, this disables all navigation bars for all views associated with this main view.

I also change the color of the upper navigation bars of the sub pages, but this does not work either. I am running the application on an emulator, but the changes do not seem to be affected.

Can anyone advise? I am new to c object (mostly Java experience) and would like to quickly get the application. My problem is time, and Storyboard seems to have solved this, since I can get something together pretty quickly.

+4
source share
3 answers

I just started the application and had the same problem, the line you are looking for:

self.navigationController.navigationBar.hidden = YES; 

Full code:

 - (void)viewWillAppear:(BOOL)animated { self.navigationController.navigationBar.hidden = YES; } 

Make sure you enable it using the following controller:

 self.navigationController.navigationBar.hidden = NO; 

It was tested only in a later version of Xcode, but should work just fine for 4.6.3

(edit to change from viewDidLoad to viewWillAppear)

+17
source

in swift you can use almost obvious

 self.navigationController?.navigationBar.isHidden = true; 

and

 self.navigationController?.navigationBar.isHidden = false; 

to show or hide the navigation bar. make sure you enable view loading, so call them in viewWillAppear or viewDidAppear.

+1
source

It may be an old post, but it seems relevant. I ran into this problem and thought it might be useful to upgrade to Swift version 4.

Swift 4

 override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) navigationController?.setNavigationBarHidden(true, animated: false) } override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) navigationController?.setNavigationBarHidden(false, animated: true) } 

For example, you should insert it into the controller of the initial view, where you do not want to see the navigation bar. This will hide the navigation bar. And revive it in sight for the next session.

One thing to keep in mind as it animates you, you need to make sure that your restrictions are not aligned to preserve the area that includes the navigation bar, but rather for viewing.

We hope that this will be useful.

0
source

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


All Articles