iOS2012. 9. 13. 23:49

I just want to enable/disable the status bar per view controller (some view full screen, some not)

I've been several times through all the post related to the status bar 20 pixels issue, but still have the problem, especially on iOS5.0 (some trick worked on older iOS version):

Here is the problem definition:

  • I use [[UIApplication sharedApplication] setStatusBarHidden:YES] to hide the status bar

  • I always have the 20 pixel height white empty area if I do this

  • I've try to enable/disable the navigation bar to force a layout, this does not works on iOS 5:

    [self.navigationController setNavigationBarHidden:NO animated:NO];
    [self.navigationController setNavigationBarHidden:YES animated:NO];
  • I've try to manually reset the view frame size, no change

    self.view.frame=CGRectMake(0, 0, 320, 480);

  • I've tried to change manually the navigation container view:

    self.navigationController.frame=CGRectMake(0, 0, 320, 480);

  • All the view are of course 480 pixels height

share|improve this question

62% accept rate
First try to improve your accept rate it's too low – Wolvorin Jul 27 at 13:27
so you have a tip @AalokParikh ? – tomsoft Aug 8 at 17:59
I use this to show and hide the statusbar [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; And also design view according to the statusbar's hidden status ie. If statusbar is hidden I design my View with no statusbar in it. :) – Wolvorin Aug 9 at 9:37
well, I've tried this too , but the beahvior also is different depending of the iOS version. I've finally had to rewrite completely the navigation framework in order to be 100% sur to manage it... – tomsoft Aug 9 at 11:59
Oh I dont get any difference or not been able to detect it sorry :( – Wolvorin Aug 9 at 12:00
show 2 more comments
Was this post useful to you?     

Use the following method in viewWillAppear of view controller to which you would like to display StatusBar.

[[UIApplication sharedApplication]setStatusBarHidden:YES];

Declare one BOOL variable to indicate whether status bar is hidden or not while view is loaded in view controller which you would like to hide status bar and set its value to NO.

BOOL statusBarHidden = NO;

Then add the following code in viewWillAppear of view controller(Status Bar is hidden in this view)

[[UIApplication sharedApplication] setStatusBarHidden:YES];
if(statusBarHidden == NO)
{
   
self.navigationController.navigationBar.frame = CGRectOffset(self.navigationController.navigationBar.frame, 0.0, -20.0);
    statusBarHidden
= YES;

}

Posted by 다오나무