需求如下:
1.app整体只能竖屏,部分页面才可以横屏
2.app整体只能竖屏,部分页面也是竖屏,但是点击某个按钮可以使当前页面变为横屏,如全屏视频播放键。
需求1解决方法:
1.在targets - general中设置设备支持方向如下,确保设备各个方法均支持
屏幕快照 2016-12-08 下午6.41.26.png
2.在appdelegate的.h文件声明属性来标记当前设备方向@property (assign , nonatomic)UIInterfaceOrientation interfaceOrientation;
在appdelegate的.m文件中:- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window {
if(self.interfaceOrientation == UIInterfaceOrientationUnknown) { // 直播间用
return UIInterfaceOrientationMaskAllButUpsideDown;
} else if(self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
//交易页面横屏用
return UIInterfaceOrientationMaskLandscapeRight;
} else { ret