iOS 横屏模态进入下一级界面, 竖屏退出

首先 Deployment Info 设置 除了 Upside Down 都勾选
然后,在AppDelegate.h 文件中 添加属性 @property(nonatomic,assign)NSInteger allowRotation;
在 AppDelegate.m 文件中, 添加方法
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if (_allowRotation == 1) {
return UIInterfaceOrientationMaskLandscape;
}
return UIInterfaceOrientationMaskPortrait;
}
////////////
使用方法
在要模态进入的 viewController 中
viewDidLoad 中 ,添加
AppDelegate * appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate.allowRotation = 1;
// 在 这个viewController 即将退出的时候
AppDelegate * appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate.allowRotation = 0;
没有那个时代犹如现在,知识的爆发和技术的进步如此的迅速,必须不断的学习才能紧跟时代的步伐 . (PS:资料来源比较复杂 ,如有侵权 , 删)

浙公网安备 33010602011771号