Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation bar disappears when pushing to the next viewController

Currently the home page of my application hides the navigation bar; however, whenever I attempt to push that controller over to the next viewController it also hides that navigation bar too. I currently have this is the view controller WITHOUT a navigation bar:

[self.navigationController pushViewController: mapView animated:YES];

Whenever this pushes to the next one it does not have one anymore. The next viewController's navigation bar is in the viewWillAppear method, so it should show up. Any ideas?

ANSWER:

If you hide your navigation bar in a ViewController and wish to show it in the next one then use the following code:

someVC *VC = [[someVC alloc] init];
self.navigationController.navigationBarHidden=NO;
[self.navigationController pushViewController: VC animated:YES];

@LithuT.V and @Tendulkar Thank you!

like image 612
Lalalalalala Avatar asked Sep 18 '13 05:09

Lalalalalala


People also ask

Does bottomnavigationbar disappear when we push to a new screen?

However, unlike iOS, when we Navigator.push to a new screen, this bottomNavigationBar disappears. In my app, I want to fulfil this requirement: Home screen has a bottomNavigationBar with 2 items ( a & b) presenting screen A & B.

How do I get to the navigation bar from Screen B?

By default, screen A is displayed. Inside screen A, there is a button. Tap that button, Navigator.push to screen C. Now in screen C, we can still see the bottomNavigationBar. Tap item b, I go to screen B. Now in screen B, tap item a in the bottomNavigationBar, I go back to screen C (not A, A is currently below C in the navigation hierarchy).

Where is the uitabbarcontroller in iOS?

In iOS, we have a UITabBarController which stays permanently at the bottom of the screen when we push to a new ViewController. In iOS, we have a UITabBarController which stays permanently at the bottom of the screen when we push to a new ViewController.


3 Answers

Write this code in the ViewDidload method of mapView

[self.navigationController.navigationBar setHidden:NO];
like image 104
Tendulkar Avatar answered Oct 29 '22 04:10

Tendulkar


I spent two hours trying to show my navigation bar on a view controller pushed from a different storyboard.

Note that only one navigation controller is needed in main storyboard, then for your view controller where the navigation bar disappears hide it and show it again by the following code.

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [self.navigationController setNavigationBarHidden:YES animated:YES];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
like image 25
Ahmed Elashker Avatar answered Oct 29 '22 05:10

Ahmed Elashker


I guess your are hiding your navbar from storyboard, try the below code:

//Show navigationBar for a particular VC

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

-(void)viewWillDisappear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:YES];
}
like image 1
Tarek Hallak Avatar answered Oct 29 '22 04:10

Tarek Hallak