- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self setInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//状态栏样式
- (UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleDefault;
}
//状态栏显示/隐藏
-(BOOL)prefersStatusBarHidden{
return NO;
}
//强制转屏(这个方法最好放在BaseVController中)
- (void)setInterfaceOrientation:(UIInterfaceOrientation)orientation{
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector = NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
// 从2开始是因为前两个参数已经被selector和target占用
[invocation setArgument:&orientation atIndex:2];
[invocation invoke];
}
}
//必须返回YES
- (BOOL)shouldAutorotate{
return YES;
}
//旋转方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscapeRight;
}
//- (BOOL)shouldAutorotate{
// return NO;
//}
//- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
// return UIInterfaceOrientationMaskLandscapeRight;
//}
//- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
// return UIInterfaceOrientationLandscapeRight;
//}
iOS 强制旋转app方向(含状态栏)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 状态栏旋转详见 界面旋转准备 在AppDelegate.h中添加属性 在AppDelegate.m中添加方法 进入...
- iOS 获取屏幕方向 建议使用[UIApplication sharedApplication].statusBa...
- 下面截图给出修改 iOS 状态栏颜色的 4 种方式 其中第四张图中的代码,直接写在你的任何一个 ViewContr...