2018-07-03

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;

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容