15
votes

In iOS 7.0, I hid the status bar in my apps by adding

<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

to the info.plist. I just updated my testing iPad to iOS 7.1, and the status bar is now back in all of my apps. How can I hide it in both 7.0 and 7.1?

Update: This is only happening in iPhone apps running on the iPad, I don't see this problem on the iPhone or in the simulator.

5
I'm starting to think it's a bug in iOS 7.1 and I'll just have to wait for Apple to fix it.Brian
I submitted a bug report to Apple. If anyone finds a workaround before they fix this (assuming they do), please post it here.Brian
Any news about that? any solution or workaround ?AmineG
I got a confirmation email from Apple, but that was it. Hopefully it will be fixed in 7.1.1.Brian
any solution to this yet? just came across this problem too...user2431285

5 Answers

1
votes

In the view controllers in which you want the status bar hidden, add the following method

- (BOOL)preferStatusBarHidden {
  return YES;
}

Then you can call

[self setNeedsStatusBarAppearanceUpdate];

which will fire the change to the status bar. This call can be done inside of an animation block which will animate the change.

1
votes

Try adding the following

   - (void)viewWillAppear:(BOOL)animated{
        NSLog(@"View will appear");
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

    }

    - (void)viewWillDisappear:(BOOL)animated{

        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
    }
1
votes

I can reproduce the problem with a single-view iPhone-only app running in iPhone-compatibility mode in the simulator. But only when selecting an iPad non-retina on iOS 7.1.

My findings:

  • The status bar will not be hidden, whatever you specified in the plist or in code.
  • The problem doesn't occur on retina iPads
  • The problem doesn't occur on iOS 7 or iOS 6

I tried these keys in the .plist:

<key>UIStatusBarHidden</key>
<true/>
<key>UIStatusBarHidden~ipad</key>
<true/>

and

<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIViewControllerBasedStatusBarAppearance~ipad</key>
<false/>

I also tried the ViewController based-solution as mentioned by @Irfan to no avail.

There also seems no way to detect if the statusbar is shown as [UIApplication sharedApplication].statusBarFrame returns {0, 0, 0, 0}

0
votes

Add this to ViewDidLoad:

 [[UIApplication sharedApplication] setStatusBarHidden:YES
                                        withAnimation:UIStatusBarAnimationFade];

And Implement below Method:

- (BOOL)prefersStatusBarHidden {
return YES;
 }

It will hide status-bar of that particular ViewController in which you Implement it. It works superbly good for me. Hopefully it will also help you out.

0
votes

The only solution I have found to this is to add the following:

- (UIStatusBarStyle) preferredStatusBarStyle {
    return -1;
}

wherever you have:

- (BOOL)prefersStatusBarHidden {
    return YES;
}

This is obviously terrible, but it seems to work for me -- at least so far.

UPDATE: I have noticed this causing output like the following:

<Error>: CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

I find another workaround, and it's possible that this error is what makes this workaround work, so I'm sticking with it, but it's worth noting.