728x90 반응형 가로모드막기1 [iOS/UI] 가로모드 막기(UIInterfaceOrientationMask.portrait) 가로모드를 막는 방법은 간단하다. 앱딜리게이트에 shouldSupporAllOrientation이라는 변수를 만들어주고 supportedInterfaceOrientationFor 함수에 변수가 true면 모든 방향을 가능하게 하고 false면 세로모드만 가능하게 하라라고 설정해준 뒤 가로모드를 막고싶은 뷰컨트롤러에 AppDelegate를 대신할 상수를 만들주고 viewDidLoad()에 appdelegate에 아까 만들어놨던 변수 shouldSupportAllOrientation를 false로 바꿔주면 된다. 아래 왼쪽은 가로모드를 막기 전이고 오른쪽은 적용한 후의 모습이다. 2020. 1. 5. 이전 1 다음 728x90 반응형