问题描述
我正在将代码从iOS 8升级到iOS9.我的程序中有一个代码段[[UIApplication applicationName] setStatusBarHidden:YES];
.
I am upgrading my code from iOS 8 to iOS 9. I have a code snippet in my program[[UIApplication applicationName] setStatusBarHidden:YES];
.
我收到警告"iOS 9.0中已弃用setStatusBarHidden,请使用-[UIViewController preferredsStatusBarHidden"".如果我仅将'setStatusBarHidden'替换为'prefersStatusBarHidden',则会得到'找不到实例方法'.有人可以建议我如何解决这个问题吗?
I am getting the warning "setStatusBarHidden is deprecated in iOS 9.0, Use -[UIViewController prefersStatusBarHidden". If I just replace 'setStatusBarHidden' with 'prefersStatusBarHidden', I get 'instance method not found'.Can someone please suggest me how to solve this problem?
推荐答案
将以下代码添加到视图控制器中.
Add below code to your view controller..
- (BOOL)prefersStatusBarHidden {
return NO;
}
注意:
- 如果您更改此方法的返回值,请调用
setNeedsStatusBarAppearanceUpdate
方法. - 对于childViewController,要指定一个子视图控制器应该控制首选状态栏的隐藏/未隐藏状态,实施
childViewControllerForStatusBarHidden
方法.
- If you change the return value for this method, call the
setNeedsStatusBarAppearanceUpdate
method. - For childViewController, To specify that a child view controllershould control preferred status bar hidden/unhidden state, implementthe
childViewControllerForStatusBarHidden
method.
这篇关于在iOS 9.0中已弃用setStatusBarHidden的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!