Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NavigationBar contents disappear on pop from view with prefersStatusBarHidden = YES

I have a fairly straightforward setup in my iPhone app, with a navigation controller and a view controller. The view controller has a title, and for most of my views, pushing other view controllers works as expected: the title is used as the label for the "back" button on the navigation bar, and the new view is shown. After the new view has been popped from the stack, the old view is shown with its title.

However, as soon as the pushed view controller implements prefersStatusBarHidden with the return value YES, the title in the navigation bar is gone after this view is popped from the stack - it remains empty and doesn't even display my custom rightbarbuttonitem.

Additionally, doing this in landscape instead of portrait does not show this behaviour - the title is displayed correctly. If you encounter this issue in portrait, you could turn the phone to landscape and back to portrait again, and the title and everything else will reappear in place.

I am unsure if this was already there in previous versions of iOS, but I am currently seeing it with iOS 8.

like image 907
Philipp Avatar asked Sep 30 '22 18:09

Philipp


1 Answers

I had the same issue and the workaround for me was this:

In the view controller that is having prefersStatusBarHidden set to YES add:

- (void)viewWillDisappear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:YES];
    [self.navigationController setNavigationBarHidden:NO];
}
like image 114
losic Avatar answered Oct 04 '22 03:10

losic