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

  • 相关阅读:
    MySQL——字符串拆分(含分隔符的字符串截取)
    一列数据组合成字符串并用逗号隔开
    web最大化,最小化文字错位的问题
    Esxi虚拟机安装Ros+Openwrt软路由双系统简单分享(踩到的坑,很大的坑)
    跟着老司机免费申请一个域名去!
    logging模块
    os.rename 和os.replace
    装饰器详解
    python if not
    globals和locals的区别
  • 原文地址:https://www.cnblogs.com/cnsec/p/11515827.html
Copyright © 2011-2022 走看看