zoukankan      html  css  js  c++  java
  • iOS不勾选设置,实现某个界面强制横屏

     1、在不勾选横屏的前提下,实现某一个界面横屏显示,比如播放视频、图表显示等。

    2、只能Present跳转,Push会无效。

    3、实现代码

         在需要横屏的VC里,添加如下代码     

    #pragma mark 强制横屏(针对present方式)
    - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
        return (UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft);
    }
    
    - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
    }
    
    //必须有
    -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
        return UIInterfaceOrientationLandscapeRight;
    }
    

      

    4、最终效果

    5、其他补充描述

    - 这样设置后,当前页面的坐标原点会变成横屏下的左上角,所以适配规则要按照这个来做。

    - 横屏下状态栏是看不到的,这是系统默认实现。

    - 这种方式,即使手机本身设置了禁止旋转,也是可以旋转的,所以也是强制旋转。

  • 相关阅读:
    Day10
    Day9
    Day8
    安装出错
    安装步骤
    技术面试
    工作机会查找
    selenium 关于富文本的处理
    selenium查找动态的iframe的name
    eclipse项目debug方法
  • 原文地址:https://www.cnblogs.com/yajunLi/p/6264788.html
Copyright © 2011-2022 走看看