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。

     

  • 相关阅读:
    eclipse 闪退原因
    Ansj分词的使用
    pycharm实现sublime的显示效果,很惊艳哦
    使用pycharm以及用pycharm句子切分调试
    安装pytorch0.4.0
    vim设置一个tab为4个空格,设置行号
    读取html文件,让其中的内容和notepad打开这个html的样子一样。
    把变量,比如矩阵的值存储到文件里面去
    xpath分析 html文件抽正文的过程
    quepy
  • 原文地址:https://www.cnblogs.com/StarMud/p/2749866.html
Copyright © 2011-2022 走看看