Mobile/iOS

[iOS]화면 회전 제어하기

out of coding 2016. 3. 22. 16:55

iOS장비의 화면중에 회전을 제어하여야 하는 화면이 있으면 다음과 같이 설정하여서 개발하도록 합니다.

방법은 쉽고, UIViewController에 넣어주면 된다.


(Objective-C 코드)


- (UIInterfaceOrientationMask)supportedInterfaceOrientations {

return UIInterfaceOrientationMaskPortrait;

}


* 옵션

UIInterfaceOrientationMaskPortrait : 세로 화면만 허용

UIInterfaceOrientationMaskAll : 전체 화면 허용

UIInterfaceOrientationMaskPortraitUpsideDown : 거꾸로만 허용

UIInterfaceOrientationMaskLandscape : 가로화면만 허용


(Swift 코드)

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {

        return UIInterfaceOrientationMask.Portrait

}


* 옵션

UIInterfaceOrientationMask.Portrait : 세로 화면만 허용

UIInterfaceOrientationMask.All : 전체 화면 허용

UIInterfaceOrientationMask.PortraitUpsideDown : 거꾸로만 허용

UIInterfaceOrientationMask.Landscape : 가로화면만 허용