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
iPhone/iOS Status bar not hiding in Xcode project
提问by Zigglzworth
Hi I have tried the following but am unable to remove the status bar from my application:
您好,我尝试了以下操作,但无法从我的应用程序中删除状态栏:
- Set status bar is initially hidden to YES in plist
- 'Hide during application launch' to ticked in Project General settings
- Set status bar to 'none' in the interface builder file controlling view controllers
- Set [UIApplication sharedApplication].statusBarHidden = YES; in app delegate.
- 设置状态栏最初在 plist 中隐藏为 YES
- 在项目常规设置中勾选“在应用程序启动期间隐藏”
- 在控制视图控制器的界面构建器文件中将状态栏设置为“无”
- 设置 [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
回答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;
}