zoukankan      html  css  js  c++  java
  • Rotation IOS6与ios5和ios4屏幕旋转的区别

    在iOS5.1 和 之前的版本中, 我们通常利用 shouldAutorotateToInterfaceOrientation: 单独控制某个UIViewController的旋屏方向支持,也就是说各个ViewController各自独立管理自己的旋转方向,跟其他ViewController或NavigationController没有关系,比如:

    1. (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    2. {//interfaceOrientation表示当前设备旋转到的方向,返回YES则表示界面也旋转到这个方向,NO则不
    3.     return (interfaceOrientation == UIInterfaceOrientationPortrait);
    4. }
    但是在iOS6中,这个方法被废弃了,使用无效

    在IOS6中的每个ViewController中代替使用:
    1. -(BOOL)shouldAutorotate
    2. {
    3.     return NO;//YES  支持旋转到supportedInterfaceOrientations函数所指定的方向  NO 则完全不支持旋转  始终保持正屏(UIInterfaceOrientationMaskPortrait)
    4. }

    5. -(NSUInteger)supportedInterfaceOrientations
    6. {
    7.     return UIInterfaceOrientationMaskPortrait; //当shouldAutorotate函数返回YES 指定的值才起作用
    8. }

    这里有一个问题,当是用UINavigationController管理ViewController时,在各个viewController中制定的这两个函数必须要一样,不然会崩,于是一般自定义UINavigationController,然后在这里面重写这两个方法,这样之后,在每个具体ViewController中的指定就不会起作用,这样便于统一各个界面的旋转风格,但不适合有界面旋转风格不同的情况

    for ios 4 and 5, 如果没有重写shouldAutorotateToInterfaceOrientation,那么对于iphone来讲,by default是只支持portrait,不能旋转。

    for ios 6, 如果没有重写shouldAutorotate and supportedInterfaceOrientations,by default, iphone则是"可以旋转,支持非upside down的方向",而ipad是"可以选择,支持所有方向"

    http://blog.csdn.net/totogogo/article/details/8002173
    http://palmsky.net/?p=3232

  • 相关阅读:
    Yii2 数据操作Query Builder
    Yii2.0 rules验证规则大全
    git错误解决 -- 小结
    为什么结构化编程、面向对象编程、软件工程、架构设计最后没有成为软件领域的银弹
    系统和子系统、架构和框架、模块和组件
    MyBatis实战之动态SQL
    Controller如何写的更简化
    MyBatis实战之映射器
    WiFi密码忘记了怎么办之解决方案
    Linux常用监控服务器性能命令
  • 原文地址:https://www.cnblogs.com/cnsec/p/11515827.html
Copyright © 2011-2022 走看看