zoukankan      html  css  js  c++  java
  • iOS 6.0以上版本的旋屏控制处理

    我们都知道,在iOS 6.0以下,支持旋屏的函数如下:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

    我们只要对不同的interfaceOrientation返回YES或NO即可支持对应的屏幕旋转。在6.0以后,旋转函数改为:

    - (NSUInteger)supportedInterfaceOrientations

    需要自己返回对应的orientations。

    但是在实践中发现,当个controller的supportedInterfaceOrientations根本没有调用。经过查看资料分析,原来在6.0以上,旋屏的控制放在了navgationController,所以我们需要自定义一个navgationController,定义相关的变量来处理是否支持旋转。

    //写子类NavigationController的目的是因为6.0以上,把旋屏的控制放在了UINavigationController

     @interface LRNavigationController : UINavigationController

     //是否支持旋屏幕

    @property(nonatomic,assign)BOOL shouldRotate;

     @end

    实现如下:

    @implementation LRNavigationController

     @synthesize shouldRotate = _shouldRotate;

    #pragma  mark roate method

    - (BOOL)shouldAutorotate

    {

        return_shouldRotate;

    }

     - (NSUInteger)supportedInterfaceOrientations{

        return_shouldRotate ? UIInterfaceOrientationMaskAllButUpsideDown : UIInterfaceOrientationMaskPortrait;

    }

    这样在6.0以上,就可以通过获取navgationController更改_shouldRotate的值,实现旋转的控制。

     

     

  • 相关阅读:
    事件处理器(eventhandler,或称为事件处理程序)onload
    HTML语言中img标签的alt属性和title属性的作用于区别
    nexus 开机自启动
    idea 上传jar包到nexus
    Spark standalone HA
    spark 性能优化指南
    spark 体验点滴- executor 数量 和task 并行数
    spark 体验点滴-client 与 cluster 部署
    aop concepts
    部署jar到linux ,开机自启动
  • 原文地址:https://www.cnblogs.com/vicstudio/p/3102621.html
Copyright © 2011-2022 走看看