Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide navigationbar when i push from navigation controller?

how to hide top bar in UIViewcontroller when i push from navigation controller using pushViewController ? any help please?

like image 909
senthilM Avatar asked Oct 24 '09 10:10

senthilM


People also ask

How do I make my navigation bar auto hide?

Way 1: 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 push a controller without navigation controller?

You can't push a view controller onto a navigation controller if there is no navigation controller. If you are wanting to be pushing controllers and have it display the topmost controller and everything, just use a UINavigationController and be done with it.


2 Answers

Put this code in the view controller you want to hide the navigation bar for.

- (void) viewWillAppear:(BOOL)animated {     [super viewWillAppear:animated];     [self.navigationController setNavigationBarHidden:YES animated:animated]; } 

And you may also want to stick this in there, depending on your needs:

- (void) viewWillDisappear:(BOOL)animated {     [super viewWillDisappear:animated];     [self.navigationController setNavigationBarHidden:NO animated:animated]; } 
like image 85
Ed Marty Avatar answered Sep 27 '22 17:09

Ed Marty


Here's how to do it in Swift 3:

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

P.S. I found that if you set animated to false, a black bar appears on push. But when it is set to true it's smooth as silk!

like image 25
dustinrwh Avatar answered Sep 27 '22 15:09

dustinrwh