应用整体只支持竖屏,只有特定的某个界面支持横屏
解决方法:
1.在项目中plist文件中设置支持转屏方向
转屏控制级别: tabar>导航控制器>普通控制器
2.在tabbar/ 导航控制器/ 普通控制器 的.m文件中 复写以下三个方法
|
|
1)TabBarVC 中重写三个方法的代码如下:
2)导航控制器基类中重写三个方法的代码如下:
3)普通控制器基类中代码如下:
针对没有tabbar,只有导航控制器的应用,可以直接省去TabBarVC中方法重写代码;
3.因为项目的大多控制器是不支持自动转屏,且只支持竖屏;因此这些ViewController 继承自BaseViewController;
针对特定的需要支持 左右横屏的视频播放界面,仍需要复写以上三个方法
代码手动设置横屏, [ [UIDevice currentDevice] setValue: forKey: ]
会调用 方法- (BOOL)shouldAutorotate
,如果该方法返回的是NO,则无法使用代码设置横屏;
所有需要在调用前 设置_autoRotate = YES
; 调用完毕设置_autoRotate = YES
;
注意事项:
当手机横放,已经是物理横屏的时候,再手动设置横屏是无效的;所以此处需要做处理(如果是物理横屏,先恢复为物理竖屏)