How to hide UIStatusBar and show UINavigationBar at the top when UIView changes to LandscapeOrientat

Posted by KayKay on Stack Overflow See other posts from Stack Overflow or by KayKay
Published on 2010-05-04T09:50:47Z Indexed on 2010/05/05 5:58 UTC
Read the original article Hit count: 853

I am using two views (portraitView and landscapeView) loaded from xib in a viewcontroller for different InterfaceOrientation each for Portrait and Landscape mode. The view in portrait mode has statusbar and navigationbar and other one has just the navigationbar. The problem is that even i made statusbar hidden programatically the view in Landscape mode has blank space left at the position of statusbar and below is navigationbar which is for sure looking embarrassing.

Is it possible to put the navigationbar at the top - replacing the statusbar position. I tried many options like.

 if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
     interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
    [[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
    self.navigationController.navigationBarHidden = NO;
    [[self view] setFrame:CGRectMake(0, 0, 480, 320)];
    self.navigationController.wantsFullScreenLayout = YES;
    self.view = self.landscapeView;
}

But despite all this efforts it only lefts the same 20x480 pixels blank space and below it navigationbar. But here there is no end to trouble when I switch back to portraitView, the navigation bar hides behind the statusbar mere showing remaining 320x(44-20)px on top. Please help and thanks in advance.

© Stack Overflow or respective owner

Related posts about statusbar

Related posts about uinavigationbar