zoukankan      html  css  js  c++  java
  • UIDeviceOrientation & UIInterfaceOrientation & UIInterfaceOrientationMask

    1、UIDeviceOrientation

    UIDeviceOrientation的定义在UIDevice.h中,它的定义如下:

    //  UIDevice.h

    ... 

    typedef NS_ENUM(NSInteger, UIDeviceOrientation) {

        UIDeviceOrientationUnknown,

        UIDeviceOrientationPortrait,               // Device oriented vertically, home button on the bottom

        UIDeviceOrientationPortraitUpsideDown,     // Device oriented vertically, home button on the top  

        UIDeviceOrientationLandscapeLeft,            // Device oriented horizontally, home button on the right

        UIDeviceOrientationLandscapeRight,         // Device oriented horizontally, home button on the left

        UIDeviceOrientationFaceUp,                     // Device oriented flat, face up 

        UIDeviceOrientationFaceDown                  // Device oriented flat, face down

    };

    由此可见,设备方向有7种,这是一个三维的方向体系,每个方向一种,再加上一种不可判断的。

    人为判断设备方向的方法:通过home按钮定位。注意:设备方向左时home按钮在右边,设备方向右时home按钮在左边。

    程序获取设备方向的方法是:[[UIDevicecurrentDevice] orientation]

     

    2、UIInterfaceOrientation 

    UIInterfaceOrientation的定义在UIApplication.h中,它的定义如下:

    //

    //  UIApplication.h

    ...

    // Note that UIInterfaceOrientationLandscapeLeft is equal to UIDeviceOrientationLandscapeRight (and vice versa).

    // This is because rotating the device to the left requires rotating the content to the right.

    typedef NS_ENUM(NSInteger, UIInterfaceOrientation) {

        UIInterfaceOrientationPortrait               = UIDeviceOrientationPortrait,

        UIInterfaceOrientationPortraitUpsideDown   = UIDeviceOrientationPortraitUpsideDown,

        UIInterfaceOrientationLandscapeLeft            = UIDeviceOrientationLandscapeRight,

        UIInterfaceOrientationLandscapeRight          = UIDeviceOrientationLandscapeLeft

    };

    由此可见,界面方向是二维的,界面方向的左和右跟home按钮的左右相同。

    人工判断界面方向的方法是:木有方法判断界面方向,界面方向取决于程序实现。

    程序获取界面方向的方法是:[[UIApplicationsharedApplication] statusBarOrientation]

     

    3.UIInterfaceOrientationMask

    UIInterfaceOrientation的定义在UIApplication.h中,它的定义如下:

    //

    //  UIApplication.h

    ...

    typedef NS_OPTIONS(NSUInteger, UIInterfaceOrientationMask) {

        UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),

        UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),

        UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),

        UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),

        UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),

        UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),

        UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),

    };

    由UIInterfaceOrientationMask的名称可以知道,它只是为了支持多种UIInterfaceOrientation而定义的类型。

    它跟UIViewController相关,在UIViewController中可以通过[self supportedInterfaceOrientations]获取支持的UIInterfaceOrientation。

     

  • 相关阅读:
    第02组 Beta版本演示
    2020系统综合实践8 大作业 智能门禁
    2020系统综合实践6 树莓派基本入门
    2020系统综合实践5 使用Dokcer部署Python运行环境
    2020系统综合实践4 Dokcer专题实践
    2020系统综合实践3 使用Docker Compose部署LNMP
    2020系统综合实践2 使用Dokcer部署Nginx和MySQL容器
    2020系统综合实践1 WSL 2的安装和基本使用
    2020系统综合实践1 VirtualBox下安装Debian踩坑小结
    团队第六次——beta冲刺日志集合
  • 原文地址:https://www.cnblogs.com/StarMud/p/2749866.html
Copyright © 2011-2022 走看看