Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setStatusBarHidden not working

Tags:

ios

In my UIViewController, I have:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
    [self.view sizeToFit];
}

Yet the view looks like this:

enter image description here

I'm sure this code runs. I load the view from a xib. I haven't done anything else to the status bar like change its style. What could be wrong?

Even when I set `application.statusBarHidden = YES" in my app delegate, I see:

enter image description here

like image 314
Rose Perrone Avatar asked Aug 18 '13 21:08

Rose Perrone


3 Answers

In your app's plist, if you have "View controller-based status bar appearance" set to YES, put this code in the view controller in which you hide the status bar:

- (BOOL)prefersStatusBarHidden {     return YES; } 

Else if "View controller-based status bar appearance" is set to NO, call the following whenever you want to hide the status bar.

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; 
like image 113
Rose Perrone Avatar answered Oct 06 '22 00:10

Rose Perrone


if you want to hide Status Bar in your app , Follow this steps :

Step 1 :

enter image description here

Step 2:

enter image description here

Step 3:

Add to your appDelegate didFinishLaunchingWithOptions function

application.statusBarHidden = YES; 

so :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {       application.statusBarHidden = YES; } 
like image 24
Erhan Demirci Avatar answered Oct 06 '22 00:10

Erhan Demirci


That's because iOS 7 has changed the way it deals with the status bar.

Setting UIViewControllerBasedStatusBarAppearance to NO on your app Info.plist should work.

like image 26
Marcelo Fabri Avatar answered Oct 05 '22 23:10

Marcelo Fabri