info.plist文件中,View controller-based status bar appearance项设为YES,则View controller对status bar的设置优先级高于application的设置。
如果View controller-based status bar appearance 设为NO,这时application的设置优先级最高
我通常设为NO, 使application的设置优先级最高. 这时运行App, 状态栏会消失, 需要在启动函数后设置显示状态栏.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[NSThread sleepForTimeInterval:1];
// 需要在启动函数后设置显示状态栏
[UIApplication sharedApplication].statusBarHidden = NO;
}
如果遇到设置状态栏方向无效的问题, 解决方法如下:
//设置方向无效
[UIApplication sharedApplication].statusBarOrientation = orientation;
// 在所属控制器下
- (BOOL)shouldAutorotate
{
return NO;
}