xcode 尽管 PList 设置正确,状态栏仍然出现在 iOS 7 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19002957/
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 03:54:53  来源:igfitidea点击:

Status Bar still appearing in iOS 7 despite correct PList settings

iphoneiosobjective-cxcodestatusbar

提问by Smikey

I've just upgraded to XCode 5 and iOS 7. I've read all the suggestions I can find, but still getting the status bar appearing over the top of my apps.

我刚刚升级到 XCode 5 和 iOS 7。我已经阅读了我能找到的所有建议,但仍然让状态栏出现在我的应用程序顶部。

I've tried setting View controller-based status bar appearance to NO in my plist:

我已经尝试在我的 plist 中将基于视图控制器的状态栏外观设置为 NO:

enter image description here

在此处输入图片说明

I've tried adding:

我试过添加:

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

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

to my root view controller.

到我的根视图控制器。

I don't know what else to try. Am I missing something obvious?

我不知道还能尝试什么。我错过了一些明显的东西吗?

UPDATE

更新

I've found that the status bar is only present on a couple of targets, while other targets running the same code don't have the status bar. I've checked all their plists... The only difference with the ones showing the status bar are that they display an advert bar at the top of the screen... I wonder if this could have something to do with it?

我发现状态栏只出现在几个目标上,而其他运行相同代码的目标没有状态栏。我检查了他们所有的 plists...与显示状态栏的唯一区别是它们在屏幕顶部显示一个广告栏...我想知道这是否与它有关?

采纳答案by Smikey

I ended up deleting the plist file and copying one from another target that did work, and then changing the necessary values. The lists were identical, however this appeared to fix it. I had already tried clean building, reseting the simulator etc, so I guess it was a bug in the plist/xcode.

我最终删除了 plist 文件并从另一个有效的目标中复制了一个,然后更改了必要的值。列表是相同的,但是这似乎修复了它。我已经尝试过干净的构建,重置模拟器等,所以我猜这是 plist/xcode 中的一个错误。

回答by Fahri Azimov

Use - (BOOL)prefersStatusBarHidden { return YES; }in all of your view controllers. Good Luck!

使用- (BOOL)prefersStatusBarHidden { return YES; }在所有的视图控制器。祝你好运!

回答by Vlad

In application .plist add this key: UIViewControllerBasedStatusBarAppearance and set it "NO"

在应用程序 .plist 中添加此项: UIViewControllerBasedStatusBarAppearance 并将其设置为“NO”

回答by Andreas Rau

Less hacky solution is to insert

不那么hacky的解决方案是插入

[application setStatusBarHidden:YES]

in AppDelegate.m in method

在 AppDelegate.m 中的方法

- (BOOL) application(UIApplication *)application didFinishLaunchingWithOptions:(NSDirectory *)launchOptions

- (BOOL) application(UIApplication *)application didFinishLaunchingWithOptions:(NSDirectory *)launchOptions

like Dipen Panchasara his: [UIApplication sharedApplication]delivers exact the application given in the methodcall.

就像 Dipen Panchasara 他的:[UIApplication sharedApplication]提供方法调用中给出的应用程序。

Because changing a method to allways return YES feels not right

因为换一个方法总是返回YES感觉不对

回答by German Attanasio

Try to add the next code in your root view controller:

尝试在根视图控制器中添加下一个代码:

- (BOOL)prefersStatusBarHidden { return YES; }