不推荐使用setStatusBarHidden,但只能使用它 [英] setStatusBarHidden deprecated, but only thing that works

查看:2325
本文介绍了不推荐使用setStatusBarHidden,但只能使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了所有可以找到的解决方案,包括: setStatusBarHidden在iOS 9.0中已弃用但它们都不适用于我的应用程序。

I've tried all the solutions I can find including those in: setStatusBarHidden is deprecated in iOS 9.0 but none of them work with my application.

这是一个简单的单视图应用程序。导航栏上有一个按钮,状态栏应显示在其上。

It is a simple, single view application. There is a Navigation bar with a single button on it which the status bar should show on top of.

在我的.plist中:

In my .plist:


状态栏最初隐藏:否

Status bar is initially hidden: NO

状态栏样式:UIStatusBarStyleLightContent

Status bar style: UIStatusBarStyleLightContent

查看基于控制器的状态栏外观:否

View Controller based status bar appearance: NO

改变任何这些似乎都没有任何区别。我已选中状态栏样式在应用程序启动期间隐藏选项,因为我不希望它出现在初始屏幕上。

Changing any of these doesn't seem to make any difference at all. I have the status bar style "Hide during application launch" option checked as I don't want it to appear on the splash screen.

我有:

- (BOOL)prefersStatusBarHidden 
{
    return NO;
}

-(UIStatusBarStyle)preferredStatusBarStyle
{
    NSLog(@"style");
    return UIStatusBarStyleLightContent;
}

setNeedsStatusBarAppearanceUpdate 哪个肯定都是在我的ViewController中加载视图时调用的。

and setNeedsStatusBarAppearanceUpdate which are definitely all called when the view loads in my ViewController.

视图是在.storyboard中建立的,但是许多字段也在ViewController.m中被操作。分配给模拟指标中状态栏的值似乎也没有任何影响。

The view is established in a .storyboard, but many of the fields are manipulated in the ViewController.m as well. The value assigned to the status bar in the simulated metrics doesn't seem to have any effect either.

我需要在启动屏幕中隐藏状态栏并显示在viewController上。请帮我找一个不使用已弃用的setStatusbarHidden的解决方案!

I need my status bar to be hidden during the launch screen and visible on the viewController. Please help me find a solution that doesn't use the deprecated setStatusbarHidden!

编辑:

我还没有解决这个问题,我肯定不会是唯一一个遇到这个问题的人!它发生在我写的两个应用程序中。

I still haven't solved this, and I surely can't be the only one with this problem! It happens in both apps that I have written.

推荐答案

我一直试图解决同样的问题,我不知道知道为什么setStatusBarHidden和setStatusBarStyle已被弃用,因为新方法根本不直观。

I've just been trying to solve the same problem, I don't know why the setStatusBarHidden and setStatusBarStyle have been deprecated as the new methods are not at all intuitive.

要在启动时隐藏状态栏,我在plist中有这些设置:

To hide the status bar on launch I have these settings in my plist:

View controller-based status bar appearance: YES
Status bar is initially hidden: YES

然后在启动后显示状态栏我在视图控制器中:

Then to show the status bar after launch I have in my view controller:

- (BOOL)prefersStatusBarHidden {    
    return NO;
}

-(UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

在我找到这个答案https://stackoverflow.com/a/19365160/488611 。所以在viewDidLoad中我还设置了导航栏样式:

This still didn't work until I found this answer https://stackoverflow.com/a/19365160/488611. So in viewDidLoad I also set the navigation bar style:

self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

这绝对没有意义,但有效。

Which makes absolutely no sense, but works.

这篇关于不推荐使用setStatusBarHidden,但只能使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆