我刚刚把我的iPhone 5 iOS 7升级到四个测试版。现在,当我从Xcode 5在iPhone上运行我的应用程序时,状态栏没有隐藏,尽管它应该隐藏。

不工作:

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

不工作:

[UIApplication sharedApplication].statusBarHidden = YES;

无法登录苹果开发者论坛


当前回答

唯一对我有用的是在你的plist中添加以下内容

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

其他回答

Swift 2.0+ IOS 9

override func prefersStatusBarHidden() -> Bool {
return true
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
application.statusBarHidden = YES;
return YES;
}

尝试添加以下方法到你的应用程序的根视图控制器:

- (BOOL)prefersStatusBarHidden
    {
        return YES;
    }

在视图控制器中添加方法。

- (BOOL)prefersStatusBarHidden {
    return YES;
}

为了隐藏状态栏,我必须做以下两项更改:

添加以下代码到视图控制器,你想隐藏状态栏:

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

将此添加到您的。plist文件(在应用程序设置中转到'info')

View controller-based status bar appearance --- NO

然后你可以调用这一行来隐藏状态栏:

[[UIApplication sharedApplication] setStatusBarHidden:YES];