简体   繁体   English

iOS7隐藏状态栏

[英]iOS7 Hiding the status bar

I've tried everything I can think of/find to hide the status bar on iOS 7, but after the launch it appears: 我已经尝试过所有想想/发现的事情来隐藏iOS 7上的状态栏,但是在启动后会出现:

//in viewDidLoad
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

//in the main view controller
- (BOOL)prefersStatusBarHidden
{
    return YES;
}

I also set "Status bar is initially hidden", and "View controller-based status bar appearance" to YES in the info.plist. 我还将info.plist中的“状态栏最初处于隐藏状态”和“基于控制器的状态栏外观”设置为“是”。

Oddly, the status bar does hide after another controller appears, like a picker or the keyboard. 奇怪的是,状态栏的确在出现另一个控制器(如选择器或键盘)后隐藏。

Try adding a new value to your info.plist: 尝试为您的info.plist添加一个新值:

View Controller based status bar appearance - NO 基于View Controller的状态栏外观-否

If you don't want view controllers to participate in the style and visibility of the status bar, add a "View Controller based status bar appearance" row to your info.plist and set it to NO . 如果您不希望视图控制器参与状态栏的样式和可见性,请在“ info.plist ”中添加“基于视图控制器的状态栏外观”行,并将其设置为NO By default, in iOS 7, view controllers can participate in the status bar appearance process by overriding the prefersStatusBarHidden method. 默认情况下,在iOS 7中,视图控制器可以通过重写prefersStatusBarHidden方法来参与状态栏外观过程。 You could also notify UIKit about your status bar visibility change by calling [self setNeedsStatusBarAppearanceUpdate] . 您还可以通过调用[self setNeedsStatusBarAppearanceUpdate]通知UIKit有关状态栏可见性的更改。

If it's still not working, post a little bit more code to see a bigger picture of your problem. 如果仍然无法正常工作,请发布更多代码,以更全面地了解您的问题。 Maybe the cause is somewhere else. 也许原因在别的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM