본문 바로가기

프로그래밍/iOS

[ios] Orientation

 

 

1. UIInterfaceOrientation

위는 뷰 컨트롤러 상의 위치이고 deviceOrientation은 아래와 같이 반대이다.

typedef NS_ENUM(NSInteger, UIInterfaceOrientation) {

    UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,

    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,

    UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,

    UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft

 

};

 

2. DeviceOrientation 

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

 

};

 

위의 LandscapeLeft가 UIDeviceOrientationLandscapeRight​ 이며 LandscapeRight가 UIDeviceOrientationLandscapeLeft이다.

 

아이폰의 DeviceOrientation은 기기를 세웠을때만 동작한다.

화면이 하늘을 보고 있는 상태는 OrientationFaceUp이라는 다른 상태로 인식한다.

 

때문에 바닥에 놓은 FaceUP상태는 LendscapeLeft->FaceUP, Portrait->FaceUP, LendscapeRight->FaceUp, UpsideDown->FaceUp 등 여러가지 상태가 존재할 수 있다.

 

눕힌채로 아무리 가로 세로 돌려봐야 이상태는 FaceUp상태로 고정된다.

 

3. ImageOrientation

typedef enum { UIImageOrientationUp, UIImageOrientationDown, // 180 deg rotation UIImageOrientationLeft, // 90 deg CW UIImageOrientationRight, // 90 deg CCW UIImageOrientationUpMirrored, // as above but image mirrored along // other axis. horizontal flip UIImageOrientationDownMirrored, // horizontal flip UIImageOrientationLeftMirrored, // vertical flip UIImageOrientationRightMirrored, // vertical flip } UIImageOrientation;

Constants
UIImageOrientationUp
디폴트 값. 
UIImageOrientationDown
 
UIImageOrientationLeft
 
UIImageOrientationRight
 
UIImageOrientationUpMirrored
 
UIImageOrientationDownMirrored
 
UIImageOrientationLeftMirrored
 
UIImageOrientationRightMirrored
 

 

출처 : 애플 문서