1.实现指定控制器开启屏幕旋转,只是跟随手机系统是否打开竖屏锁,也就是说还不能⼿动控制屏幕的旋转,当⼿机锁定屏幕旋转时,⽆法进⾏屏幕旋
//AppDelegate里的代理方法
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
// 支持横竖屏
if ([IMManager shareInstance].horizontal) {//可在AppDelegate里设置属性
return UIInterfaceOrientationMaskAll;
} else {
return UIInterfaceOrientationMaskPortrait;
}
}
2.强制横竖屏,即使手机锁定竖屏
// 点击btn按钮
- (void)btnClick:(UIButton *)sender {
if (sender.selected) {//竖屏
[self changeOrientation:UIInterfaceOrientationPortrait];
}else{//横屏home键在右
[self changeOrientation:UIInterfaceOrientationLandscapeRight];
}
}
/**
* 强制横屏
*
* @param orientation 横屏⽅向
*/<