iPhone/iOS 状态栏未隐藏在 Xcode 项目中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22299214/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:44:06  来源:igfitidea点击:

iPhone/iOS Status bar not hiding in Xcode project

iosiphonexcodestatus

提问by Zigglzworth

Hi I have tried the following but am unable to remove the status bar from my application:

您好,我尝试了以下操作,但无法从我的应用程序中删除状态栏:

  1. Set status bar is initially hidden to YES in plist
  2. 'Hide during application launch' to ticked in Project General settings
  3. Set status bar to 'none' in the interface builder file controlling view controllers
  4. Set [UIApplication sharedApplication].statusBarHidden = YES; in app delegate.
  1. 设置状态栏最初在 plist 中隐藏为 YES
  2. 在项目常规设置中勾选“在应用程序启动期间隐藏”
  3. 在控制视图控制器的界面构建器文件中将状态栏设置为“无”
  4. 设置 [UIApplication sharedApplication].statusBarHidden = YES; 在应用程序委托中。

All these used to work fine in the 100 applications I did before but I made a recent xcode upgrade..

所有这些过去在我之前做过的 100 个应用程序中都可以正常工作,但我最近进行了 xcode 升级。

Is there some other secret way of getting rid of the status bar in the app? Do I need to journey to Apple headquarters and slay a red dragon ?

是否有其他一些秘密方法可以摆脱应用程序中的状态栏?我需要前往苹果总部并杀死一条红龙吗?

回答by Himanshu Joshi

Found the solution

找到解决方案

In your apps plist file add a row call it "View controller-based status bar appearance" and set it to NO

在您的应用程序 plist 文件中添加一行,称为“查看基于控制器的状态栏外观”并将其设置为 NO

enter image description here

在此处输入图片说明

SOURCE - OPENFL

消息来源 - OPENFL

回答by madLokesh

viewDidload

视图加载

if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
    // iOS 7
    [self prefersStatusBarHidden];
    [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
    // iOS 6
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}

Add this method

添加这个方法

- (BOOL)prefersStatusBarHidden
{
    return YES;
}