iOS(Objective c)/개발정보

xcode iOS 개발 시 화면 회전에 관한 내용

일놀 2023. 11. 20. 14:06
728x90
반응형

iOS 개발 시 화면 회전을 시키는 경우가 있다.

 

// 화면 모드 설정
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    
    return UIInterfaceOrientationMaskAll;
    
    // 옵션
    // UIInterfaceOrientationMaskPortrait : 세로 화면만 허용
    // UIInterfaceOrientationMaskAll : 전체 화면 허용
    // UIInterfaceOrientationMaskPortraitUpsideDown : 거꾸로만 허용
    // UIInterfaceOrientationMaskLandscape : 가로화면만 허용
    
}

 

 

AppDelegate.m 파일에서 이 메소드를 적용시켜주면 되는데 iPhone 에서는 제대로 동작하지만 iPad 에서는 메소드가 동작하지 않을때가 있다.

 

이 때는 프로젝트 타켁에서 General > Deployment info 에서 설정해주어야 한다.

 

 

Upside Down 이라는 항목을 체크해제 해주어야만 동작한다.

 

자세한 내용은 Document에 나와있다.

https://developer.apple.com/documentation/uikit/uiviewcontroller/1621435-supportedinterfaceorientations

 

 

 

728x90
반응형