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

不工作:

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

不工作:

[UIApplication sharedApplication].statusBarHidden = YES;

无法登录苹果开发者论坛


当前回答

2019年……

要制作一个没有状态栏的应用程序,

单击信息。plist,右键单击“添加行”。

添加这两个,设置如下:

这就是它的全部。

其他回答

在Plist中添加以下属性。

->状态栏初始隐藏= YES

->视图控制器状态栏外观= NO

添加两者-现在状态栏将消失。

要在iOS7中隐藏状态栏,你需要2行代码

inapplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions写入 (应用程序setStatusBarHidden:是的); 在信息。加上这个 基于视图-控制器的状态栏外观= NO

对于ios7在单个视图中使用viewWillappear方法:

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

显示状态栏使用:

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];

隐藏状态栏的步骤:

1.转到您的应用程序信息。plist文件。

2.和设置,查看基于控制器的状态栏外观:布尔NO

希望我解决了状态栏问题.....

我发现在整个应用程序中隐藏状态栏最简单的方法是在UIViewController上创建一个类别并覆盖prefersStatusBarHidden。这样你就不必在每个视图控制器中都写这个方法。

UIViewController+HideStatusBar.h

#import <UIKit/UIKit.h>

@interface UIViewController (HideStatusBar)

@end

UIViewController+HideStatusBar.m

#import "UIViewController+HideStatusBar.h"

@implementation UIViewController (HideStatusBar)

//Pragma Marks suppress compiler warning in LLVM. 
//Technically, you shouldn't override methods by using a category, 
//but I feel that in this case it won't hurt so long as you truly 
//want every view controller to hide the status bar. 
//Other opinions on this are definitely welcome

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

#pragma clang diagnostic pop


@end