首先  项目配置 设置支持方向

创建 UINavigationController父类、 tabbar  父类 、 uiviewcontroller 父类

UINavigationController.m 中实现


- (BOOL)shouldAutorotate {if([self.topViewController respondsToSelector:@selector(shouldAutorotate)]){return [self.topViewController shouldAutorotate];}return NO;
}- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{if([self.topViewController respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]){return [self.topViewController supportedInterfaceOrientations];}return [super supportedInterfaceOrientations];
}-(UIInterfaceOrientation) preferredInterfaceOrientationForPresentation
{if([self.topViewController respondsToSelector:@selector(preferredInterfaceOrientationForPresentation)]){return [self.topViewController preferredInterfaceOrientationForPresentation];}return [super preferredInterfaceOrientationForPresentation];
}

tabBarControllerViewController.m 中实现

// 是否支持旋转屏幕
-(BOOL)shouldAutorotate
{return [self.selectedViewController shouldAutorotate];
}// 如果支持旋转屏幕,支持旋转屏幕的方向
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{return [self.selectedViewController supportedInterfaceOrientations];
}// 默认屏幕的方向
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{return [self.selectedViewController  preferredInterfaceOrientationForPresentation];
}

uiviewcontroller.m 父类 中实现

// 默认不能旋转
-(BOOL)shouldAutorotate {return NO;
}默认只支持竖屏
-(UIInterfaceOrientationMask)supportedInterfaceOrientations {return UIInterfaceOrientationMaskPortrait;
}- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {return UIInterfaceOrientationPortrait;
}

在需要设置横屏页面设置

//支持屏幕旋转
-(BOOL)shouldAutorotate
{return YES;
}
// 支持屏幕旋转方向
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{return UIInterfaceOrientationMaskAll;// 全部方向(设备支持方向)
}
// 默认打开方向
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{return UIInterfaceOrientationPortrait;
}

遇到设备横屏打开APP 会按照横屏来布局

需要在 如下方法中添加
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{[[UIApplication sharedApplication]   setStatusBarOrientation:UIInterfaceOrientationPortrait];//此方法
}

(其他情况  若:你在didFinishLaunchingWithOptions中 加载了另一个 window 的时候,需要在改 window 中也遵守屏幕旋转的几个代理方法 否则横屏模式下打开APP布局依然会乱)

iOS屏幕自动旋转 以及横屏模式打开APP出现的问题相关推荐

  1. windows禁用屏幕旋转_如何在Windows 10中禁用屏幕自动旋转

    windows禁用屏幕旋转 Windows 10 can automatically rotate your display if you have a convertible PC or table ...

  2. iOS开发屏幕自动旋转与调整大小

    原文链接地址: http://ytwhw.iteye.com/blog/1767465 在此谢谢原博主的精心整理! 关注小白,共同成长! 苹果的产品iPad和iPhone都是支持自动旋转的,因而我们写 ...

  3. ios屏幕的旋转,Device Orientation

    屏幕旋转,我的理解是ios设备根据重力感应改变屏幕的方向.那么如何在屏幕转动后变换UI?或则保持原样呢? ios设备支持4个方向,UIInterfaceOrientationPortrait,UIIn ...

  4. android禁止屏幕自动旋转_如何禁止屏幕翻转

    Android 版需要修改 AndroidManifest.xml 文件,在文件中找到 android:screenOrientation 属性,原值应该是 user,修改成 portrait 就是锁 ...

  5. 关于IOS屏幕的旋转问题

    处理IPhone屏幕的旋转是我们经常遇到的,当你做一个应用既然满足竖屏又要满足横屏,这就要求我们会处理屏幕旋转的问题! 方法一:自动布局 1.将项目中界面的四种手持方式都点上: 2.取消Use Aut ...

  6. iOS架构-自动打包并上传到App Store(python)(21)

    这里是摘自一篇用python 语法写的脚本,这里只是为了更好的理解自动化打包上传App Store的原理的. 一. iOS 自动打包并上传到App Store(python) 我们平时大都是用Appl ...

  7. IOS 图片自动旋转

    + (UIImageView *)rotate360DegreeWithImage View:(UIImageView *)imageView{       CABasicAnimation *ani ...

  8. iphone应用程序中禁止屏幕自动旋转 自定义屏幕旋转

    在summary中的 supported devices orientation中设置所支持的屏幕旋转方式在实际RUN时并不会应用所选项目,正确的禁止屏幕旋转方向以及自定义屏幕旋转方式要在viewco ...

  9. uniapp禁止屏幕自动旋转

    1.第一步:在App.vue里添加以下代码: onLaunch: function() {// 禁止横屏// #ifdef APP-PLUSplus.screen.lockOrientation(&q ...

最新文章

  1. 跟郎朗媳妇有得一拼的AI,只看弹琴动作,完美复现原声 | CVPR 2020
  2. mysql运行正确结果显示_以下代码执行的结果是()
  3. Twiiter,下一个热点
  4. 第2题——DNA片段
  5. 数据库-ADONET-在数据集DataSet中使用关系对象DataRelation处理关系
  6. 混合文件下分离xml文件和jpg文件
  7. win10html中文乱码,Win10预览版10125中文语言包安装及乱码解决方法
  8. c语言高低位拷贝_C语言指针详解
  9. 链表的翻转(迭代法 递归法)
  10. 新开普自助查询 单点登录 php,综合教务管理系统,高校教务管理系统,教务管理系统 - 新开普(NewCapec)...
  11. 事务的acid属性是指_Mysql事务的性质 为什么要用事务?
  12. 佳能Canon PIXMA MG3020 打印机驱动
  13. 维特智能陀螺仪角度传感器原理
  14. vcenter访问报503错误处理
  15. java中的radix_int radix()
  16. Unity高质量场景打光参考资料
  17. 静态路由(也许是目前最全的)
  18. 资本寒冬之下的聚美优品私有化
  19. 一条大蟒蛇和一条小毒蛇
  20. Ubuntu 16.04 LTS 初体验

热门文章

  1. python中使用什么表示代码块、不需要使用大括号_Python3 基础语法
  2. O2O模式为什么这么火
  3. AutoCAD2018打印eps文件
  4. 小米路由器3c 虚拟服务器,小米路由器3C上不了网怎么办?
  5. autoexec.bat文件的所在位置
  6. 51.Linux 什么是线程?
  7. 学习python必备软件
  8. 【SM2证书】签发SM2根证书 (精简、直接)
  9. Google hacking用法
  10. 读书笔记(二十二):前端安全