简体   繁体   English

如何在iOS中为整个应用隐藏状态栏?

[英]How to set status bar hidden for entire app in iOS?

I am trying to set the status bar of my entire iOS app hidden. 我试图将整个iOS应用程序的状态栏设置为隐藏。 (The app deployment target is set to iOS 7.1). (应用程序部署目标设置为iOS 7.1)。

I have tried the following (and none worked): 我尝试了以下方法(但均无效果):

Adding this line to application:didFinishLaunchingWithOptions: in AppDelegate.m : 将此行添加到application:didFinishLaunchingWithOptions:中的application:didFinishLaunchingWithOptions:中:

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

and also this line: 还有这行:

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

I have tried setting the statusBar to None for each of my View Controllers in Storyboard View --> Attributes inspector --> Simulated Metrics. 我曾尝试在Storyboard View->属性检查器-> Simulated Metrics中将每个View Controller的statusBar设置为None。

I have tried adding the key Status bar is initially hidden as YES in Info.plist file of my app. 我尝试添加关键Status bar is initially hidden在我的应用程序的Info.plist文件中Status bar is initially hidden为YES。

None of these worked. 这些都不起作用。 Can anyone guide me as to what is wrong? 谁能指导我哪里出了问题? Btw, I am using the latest version of XCode on my Mac and latest iOS on my test device. 顺便说一句,我在Mac上使用最新版本的XCode,在测试设备上使用最新的iOS。 And, all my View Controllers have been set to Landscape mode only in Attributes inspector. 而且,我所有的View Controller仅在“属性”检查器中设置为“横向”模式。 And the supported orientations of the app are Landscape both sides. 该应用程序的受支持方向为横向。

Just set both properties in your .plist file.Then you will be good to go. 只需在.plist文件中设置这两个属性,然后就可以了。

1.View controller-based status bar appearance -No 1.查看基于控制器的状态栏外观-否

2.Status bar is initially hidden-YES 2.状态栏最初是隐藏的-是

Hope this will help! 希望这会有所帮助!

Have you tried setting: 您是否尝试过设置:

View controller-based status bar appearance

to NO In your Info.plist file? 否在您的Info.plist文件中?

In your info.plist file , there's a setting called "Status bar is initially hidden." info.plist文件中 ,有一个名为“状态栏最初处于隐藏状态”的设置 Set that to "YES," and you won't have it at startup. 将其设置为“是”,启动时就不会使用它。 Then you don't need to do anything in your code, the bar will show up when your app is launched. 然后,您无需在代码中执行任何操作,启动应用程序时,该栏将显示。

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

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