iOS 状态栏锁定(不随屏幕旋转)
作者:
不羁放纵dy | 来源:发表于
2017-05-16 15:59 被阅读0次笔者最近遇到一个项目.需要指定VC强制横屏.但是其他页面锁定旋转.效果是达到了.但是出现个小问题.锁定不旋转的页面的StatusBar(状态栏)是旋转的.搜索各种资料没有发现合适的解决办法.自己试验了几个办法.终于实现...分享给大家.
- 屏幕旋转时会调用如下方法(写在你的RootNavgationController中).
- (NSUInteger)supportedInterfaceOrientations {
UIViewController *vc = self.topViewController;
//如果是需要横屏的页面
if([vc isKindOfClass:[SignController class]]){
//则设置状态栏为横屏方向状态
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
return UIInterfaceOrientationMaskLandscapeLeft;
}
//如果是其他页面,则设置状态栏为竖屏方向状态
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
return UIInterfaceOrientationMaskPortrait;
}
本文标题:iOS 状态栏锁定(不随屏幕旋转)
本文链接:https://www.haomeiwen.com/subject/nyplxxtx.html
网友评论