Status bar visible on iPad mini despite setting UIViewControllerBasedStatusBarAppearance to NO

StackOverflow https://stackoverflow.com/questions/22452638

  •  15-06-2023
  •  | 
  •  

Question

I have an iPhone app with UIViewControllerBasedStatusBarAppearance set to NO. Not on any device I have tested with (iPhone 4, 5, 5s, 5c, iPad 4ish) is the status bar visible. Except on the iPad mini (1st gen). Using iOS SDK is 7.1.

The status bar is visible on iPad mini 1st gen. I expect the status bar to be hidden on this setup as well.

I even tried adding [[UIApplication sharedApplication] setStatusBarHidden:NO]; to didFinishLaunchingWithOptions but it's not changing anything.

Status Bar Style is also set to "Hide during application launch".

The iPad mini runs iOS 7.1.

Yes, it's an edge case but I just can't get it to come up with expected results this time.

One more bit of info: I'm using cocos2d-iphone v2.1. Never ran into this problem before as I have released a bunch of apps with the same engine. I'm beginning to think this is a bug relating to the combination: iOS 7.1 and iPad mini.

This is the setup:

Plist setup looks like this

Était-ce utile?

La solution 2

This is a bug in the iPad Mini iOS version 7.1.

In typical fashion, they fixed one problem (a blank status bar) and created another one.

Be sure to report the error to Apple.

Autres conseils

I faced same problem and I want to bring some explanations.

The problem occurs only when you start iPhone (only) application on iPad. If application is universal there won't be any problem. The most annoying behavior occurs using iPhone only application on iPad without Retina display. Because status bar overrides top part of application.


My plist file:

enter image description here


iPhone only application

iPhone

enter image description here

iPad:

enter image description here

iPad Retina:

enter image description here


Universal application

iPhone:

enter image description here

iPad:

enter image description here

iPad Retina:

enter image description here

You should set "View controller-based status bar appearance" YES and in every view that you want to hide call this method. Better create a base view controller all for your views and call this once.

- (BOOL)prefersStatusBarHidden {
    return YES;
}
<key>UIStatusBarHidden</key>
    <true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>

Try setting this into your info.plist file.

I have a workaround. 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.

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top