zoukankan      html  css  js  c++  java
  • ios 单个ViewController屏幕旋转

    如果需要旋转的ViewController 使用了UINavigationController,对UINavigationController进行如下扩展

    @implementation UINavigationController(shouldAutorotate)
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); }
    - (BOOL)shouldAutorotate { return self.topViewController.shouldAutorotate; }
    - (NSUInteger)supportedInterfaceOrientations { return self.topViewController.supportedInterfaceOrientations; } @end

    需要旋转的ViewController设置

     - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    {
        return YES;
    }
    
    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskAll;
    }

    其他不需要旋转的 ViewController设置,建议添加BaseViewController统一控制

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    - (BOOL)shouldAutorotate
    {
        return NO;
    }
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationPortrait;
    }
  • 相关阅读:
    二、DBMS_JOB(用于安排和管理作业队列)
    Oracle 常用系统包
    DBMS_OUTPUT(用于输入和输出信息)
    C#获取当前主机硬件信息
    Centos安装mysql5.7
    Rsync安装和配置
    利用Docker编译Hadoop 3.1.0
    hadoop集群环境搭建
    axios请求、拦截器
    import时,什么时候使用花括号'{ }'
  • 原文地址:https://www.cnblogs.com/geweb/p/shouldAutorotate.html
Copyright © 2011-2022 走看看