项目需求,app中大部分页面不支持旋转,仅指定的几个页面提供旋转支持:app
经过查询相关资料,可经过如下方法实现spa
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 这个方法是全局控制,页面旋转的。get
如须要全部页面支持旋转则,直接返回UIInterfaceOrientationMaskAll;io
- (BOOL)shouldAutorotate 控制视图控制器是否支持旋转分页
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 页面加载时优先显示的方向bug
- (UIInterfaceOrientationMask)supportedInterfaceOrientations 该视图控制器支持全部旋转的方向方法
这三个方法组合,能够防止“从指定的视图控制器(能够旋转的视图控制器)返回时,致使返回的上一个页面会存在旋转的bug”项目
以上功能的实现依赖于,在target中general栏目下已解锁多个方向(须要支持的方向)查询