UIDeviceOrientation、UIInterfaceOrientation、UIInterfaceOrientationMask區(qū)別
1、UIDeviceOrientation:設(shè)備的物理方向
typedef enum UIDeviceOrientation : NSInteger {
? ? UIDeviceOrientationUnknown, // 無(wú)法確定設(shè)備的方向
? ? UIDeviceOrientationPortrait, // 設(shè)備處于豎屏模式,設(shè)備直立,底部有home鍵
? ? UIDeviceOrientationPortraitUpsideDown, // 設(shè)備處于豎屏模式,但上下顛倒,設(shè)備保持直立,home按鈕位于頂部。
? ? UIDeviceOrientationLandscapeLeft, // 設(shè)備處于橫屏模式,設(shè)備直立,右側(cè)為home鍵
? ? UIDeviceOrientationLandscapeRight, // 設(shè)備處于橫屏模式,設(shè)備直立,左側(cè)為home鍵
? ? UIDeviceOrientationFaceUp, // 設(shè)備與地面平行,屏幕朝上 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? UIDeviceOrientationFaceDown // 設(shè)備與地面平行,屏幕朝下。
} UIDeviceOrientation;
2、UIInterfaceOrientation:應(yīng)用程序用戶界面的方向
typedef enum UIInterfaceOrientation : NSInteger {
? ? UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown,
? ? UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
? ? UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
? ? UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
? ? UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
} UIInterfaceOrientation;
注意:UIDeviceOrientationLandscapeRight分配給UIInterfaceOrientationLandscapeLeft, UIDeviceOrientationLandscapeLeft分配給UIInterfaceOrientationLandscapeRight;原因是旋轉(zhuǎn)設(shè)備需要將內(nèi)容旋轉(zhuǎn)到相反的方向。
3、UIInterfaceOrientationMask:這些常量是指定視圖控制器支持的接口方向的掩碼位
typedef enum UIInterfaceOrientationMask : NSUInteger {
? ? UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait), // 視圖控制器支持縱向界面方向。
? ? UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft), // 視圖控制器支持景觀左界面朝向
? ? UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight), // 視圖控制器支持景觀右界面朝向
? ? UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown), // 視圖控制器支持一個(gè)倒置的縱向界面方向。
? ? UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight), // 視圖控制器同時(shí)支持景觀向左和景觀向右的界面朝向
? ? UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown), // 視圖控制器支持所有的接口方向。
? ? UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight) // 視圖控制器支持所有的,除了顛倒的人像界面朝向。
} UIInterfaceOrientationMask;