iOS横竖屏设置

1.如果你的整个应用程序设置的是竖屏,如下:

如果你要应用的某个界面变为横屏,侧需要在该界面控制器中添加如下代码(前提是界面是present进去的,不是push进去的,消失要用dismiss)

 1 - (BOOL)shouldAutorotate{
 2     return NO;
 3 }
 4 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
 5      return UIInterfaceOrientationLandscapeRight;
 6 }
 7 
 8 -(UIInterfaceOrientationMask)supportedInterfaceOrientations{
 9     return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight ;
10 }
View Code

这样后到那个界面后就横屏了

原文地址:https://www.cnblogs.com/baidaye/p/5203706.html