setStatusBarHidden不起作用 [英] setStatusBarHidden not working
问题描述
在我的 UIViewController
中,我有:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[self.view sizeToFit];
}
但视图如下:
我确定这段代码运行了。我从 xib
加载视图。我没有对状态栏做任何其他事情,比如改变它的风格。可能有什么问题?
I'm sure this code runs. I load the view from a xib
. I haven't done anything else to the status bar like change its style. What could be wrong?
即使我在我的app委托中设置`application.statusBarHidden = YES',我也看到:
Even when I set `application.statusBarHidden = YES" in my app delegate, I see:
推荐答案
在您的应用程序的plist中,如果您将基于控制器的状态栏外观视图设置为YES,请将此代码放在您隐藏状态栏的视图控制器中:
In your app's plist, if you have "View controller-based status bar appearance" set to YES, put this code in the view controller in which you hide the status bar:
- (BOOL)prefersStatusBarHidden {
return YES;
}
否则如果查看基于控制器的状态栏外观设置为NO,则只要您想隐藏状态栏,就调用以下内容。
Else if "View controller-based status bar appearance" is set to NO, call the following whenever you want to hide the status bar.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
这篇关于setStatusBarHidden不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!