zoukankan      html  css  js  c++  java
  • 关于IOS屏幕旋转的几个问题1.常规设置2.个别页面强制固定横竖屏

    1.常规设置屏幕旋转  (Device Orientation || info.plist-----这两个地方的设置是同步的)

    1)targets->General->Deployment Info->Device Orientation  直接勾选想要的设备定位全局属性

    2)Supporting Files->Info.plist->Supported interface orientations 增删属性值

    2.个别页面强制横竖屏

    新建一个NavigationController类

    实现下面三个方法

    -(BOOL)shouldAutorotate

    {//是否支持自动旋转

        return YES;

    }

    -(NSUInteger)supportedInterfaceOrientations

    {//支持的旋转方向

        return [self.viewControllers.lastObject

                supportedInterfaceOrientations];

    }

    -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

    {//进入界面后的默认方向

        return [self.viewControllers.lastObject

                preferredInterfaceOrientationForPresentation];

    }

    如果push出的ViewController需要改变屏幕方向横屏或者竖屏

    在当前的ViewController中重写这三个方法,但是如果NavigationController中实现了shouldAutorotate这个方法,则在ViewController中不再执行重写的shouldAutorotate方法。

    -(BOOL)shouldAutorotate

    {//是否支持自动旋转

        return YES;

    }

    -(NSUInteger)supportedInterfaceOrientations

    {//支持的旋转方向

        return  (枚举值);

    }

    -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

    {//进入界面后的默认方向

        return  (枚举值);

    }

  • 相关阅读:
    作业5.1 四则运算----封装
    作业四
    作业2 (完)
    作业3
    作业二。。
    数独
    回答自己的提问
    《一个程序猿的生命周期》读后感
    阅读13-17章
    阅读10,11,12章
  • 原文地址:https://www.cnblogs.com/hanyutong/p/4582745.html
Copyright © 2011-2022 走看看