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;

posted @ 2017-08-22 15:28  Dingzhijie  阅读(590)  评论(0编辑  收藏  举报