• 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、其他补充描述

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

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

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

  • 相关阅读:
    目录-富爸爸穷爸爸
    目录-高效能人士的七个习惯(精华版)
    目录-卓有成效的管理者
    计算机网络自顶向下方法目录
    计算机网络_第7版_谢希仁_目录
    计算机网络各层协议
    TCP_IP详解卷一目录
    http 权威指南 目录
    Redis 知识体系
    Apache Commons 列表
  • 原文地址:https://www.cnblogs.com/yajunLi/p/6264788.html
Copyright © 2020-2023  润新知