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;

相关文章:

  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2021-05-27
  • 2021-12-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案