如何在iOS 7.1中隐藏状态栏?

如何在iOS 7.1中隐藏状态栏?

问题描述:

在iOS 7.0中,我通过添加

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

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

到info.plist。我刚刚将测试iPad更新到iOS 7.1,状态栏现在又回到了我的所有应用程序中。如何在7.0和7.1中隐藏它?

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?

更新:这只发生在iPad上运行的iPhone应用程序中,我没有在iPhone上看到这个问题或者在模拟器中。

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.

我可以通过在iPhone兼容模式下运行的单视图iPhone专用应用重现此问题在模拟器中。但只有在iOS 7.1上选择iPad非视网膜时。

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.

我的发现:


  • 状态栏不会被隐藏,无论您在plist或代码中指定的是什么。

  • 视网膜iPad上不会出现此问题

  • iOS 7或iOS 6上没有出现此问题

我在.plist中尝试了这些密钥:

I tried these keys in the .plist:

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

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

我也试过@Irfan提到的基于ViewController的解决方案无济于事。

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

似乎无法检测状态栏是否显示为[UIApplication sharedApplication] .statusBarFrame返回{0,0,0,0}

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