I have a problem which is caused by the status bar being hidden and then made to reappear – doing so changes the position of the navigation bar from being displayed below the status bar to being displayed behind it. i.e. the top part of the navigation bar can no longer be seen any more because the status bar is on top of it.
My program is constructed such that I have a root view controller that displays the status bar and the navigation bar, the view controller is contained within a navigation controller i.e.
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.myTableViewController];
self.window.rootViewController = navController;
The view controller contains a table view and if the user selects a row then another controller is created and pushed to the navigation controller’s stack.
This new view controller hides the status bar and also hides the navigation bar unless the user taps the screen, in which case the navigation bar appears (and its also translucent, which it is not in the parent view controller).
My problem is that when the user navigates from this view controller back to the table view controller then the navigation bar is now displayed behind the status bar.
I have the following code in the table view’s viewWillAppear: which I thought ought to reset everything back to the way it was.
- (void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden: NO withAnimation: UIStatusBarAnimationFade];
self.navigationController.navigationBar.translucent = NO;
[self.navigationController setNavigationBarHidden:NO animated:YES];
Why does the navigation bar appear behind the status bar when the table view re-appears?
Thanks
I believe the status bar is about 20px high, so set the navigationBar’s origin.y to be 20 and it should fix it. I know it’s annoying, but that seems to be the only way to fix it in my experience.
Also check the position of the navigationBar when your app is coming out of a background state, I know my navigationBar reverted right back to being under the status bar when it came to the foreground.