views:

568

answers:

1

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.

+1  A: 

Try this in your ViewDidAppear method,

- (void)viewDidAppear:(BOOL)animated {
if(self.view == self.landscapeView)
    [[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
else if(self.view == self.portraitView)
    [[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];
[super viewDidAppear:animated];
}
Kundan Pandit
Thanx Kundan,its working..
KayKay