Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding the status bar on a single ViewController in Storyboard

Is it possible to have the status bar hidden in just one scene in the Storyboard?

For example:

I want it hidden in "ViewController A", but when moving via a segue to "ViewController B" (eg, a Navigation Controller) the status bar will be shown.

I gather you can disable it throughout the app, but how do you do it for just one ViewController?


The suggestion from below does work, however when switching to the Navigation Controller it seems to cause the nav bar to be drawn in the wrong location.

nav bar bug

like image 474
BytesGuy Avatar asked Jun 22 '13 18:06

BytesGuy


2 Answers

How about

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarHidden:YES];

}


- (void)viewWillDisappear:(BOOL)animated{
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
    [super viewWillDisappear:animated];
}
like image 107
Gabriele Petronella Avatar answered Sep 26 '22 00:09

Gabriele Petronella


Just put the code on your ViewController.m (in iOS7, Xcode 5)

- (BOOL) prefersStatusBarHidden { return YES; }

like image 20
relaxhuang Avatar answered Sep 26 '22 00:09

relaxhuang