Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nav Bar disappearing on popviewcontroller

On one of my views, when a button is pressed I call another view that is a SplitViewController. If this SplitViewController is called via one of these buttons I have special objects to add to the view. mostly just nav bar items, like a cancel button. This view can be accessed elsewhere and these items are not needed which is why there is the special condition.

However, when the user is done and i pop the ViewController back to the previous screen that was selected, the nav bar disappears on that screen. I am not setting it to hidden nor am I doing anything strange with the nav bar. Simply adding the SplitViewController then popping back.

Some code..

//declare the split screen VC
SplitScreenViewController *split = [[SplitScreenViewController alloc] init];

//set the flag that this VC is coming from a button, so we need the extra nav bar items
[split setIsFromButton:YES];
[self.navigationController pushViewController:split animated:YES];

now the call back is simply...

- (void)cancelSelectionBtnClicked
{
     [self.navigationController popViewControllerAnimated:YES];
}

and when the view returns, the nav bar is gone.

any ideas?

edit it should be noted this exact same thing is done elsewhere the same way(as far as I can tell) and the nav bar is visible on return.

like image 297
JMD Avatar asked Feb 14 '13 14:02

JMD


2 Answers

In your ViewController's viewWillAppear you can again make your navigationBar visible.

- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO];
}
like image 176
Rajneesh071 Avatar answered Nov 20 '22 21:11

Rajneesh071


I have seen various strange navbar behavior in UISplitViewController's, and in a few cases it was because the controller was not set as the rootViewController of the window as opposed to inside a navigation controller like you have set up.

like image 44
Peter DeWeese Avatar answered Nov 20 '22 22:11

Peter DeWeese