• 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。

     

  • 相关阅读:
    zabbix api
    cassandra学习笔记
    loki grafana
    logstash配置 filebeat配置
    k8s prometheus api
    51cto 先超Prometheus+Grafana监控告警系统实战
    51cto 张岩峰 Prometheus企业级监控系统:零基础入门
    imooc 使用Prometheus实践基于Spring Boot监控告警体系 笔记
    python3 django migrate
    python3虚拟环境
  • 原文地址:https://www.cnblogs.com/StarMud/p/2749866.html
Copyright © 2020-2023  润新知