title: iOS setStatusBarOrientation 無效的解決方法
date: 2016-06-08 01:00:30
categories: "iOS"
tags:
- Objective-C
1、window.rootViewController 為VC的時(shí)候 下面兩種情況改方法仍須在VC中重寫
//控制器中重寫
- (BOOL)shouldAutorotate {
return NO;
}
2、window.rootViewController 為nav的時(shí)候
//UINavigationController 子類或者分類中重寫一下方法
- (BOOL)shouldAutorotate {
return [self.visibleViewController shouldAutorotate];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return [self.visibleViewController supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [self.visibleViewController preferredInterfaceOrientationForPresentation];
}
3、window.rootViewController 為tabBar的時(shí)候
//UITabBarController 子類或者分類中重寫一下方法
- (BOOL)shouldAutorotate {
return self.selectedViewController.shouldAutorotate;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return self.selectedViewController.supportedInterfaceOrientations;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [self.selectedViewController preferredInterfaceOrientationForPresentation];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return [self.selectedViewController preferredStatusBarStyle];
}
如果想更改狀態(tài)欄的顏色需要一下設(shè)置
需要在info.Plist 添加 View controller-based status bar appearance 設(shè)置成No,默認(rèn)為Yes
原文地址: http://oxy.pub