기존 프로젝트 코드에서 IOS15 까지는 정상적으로 회전된 상태값을 정상적으로 확인 가능했는데
IOS16 부터 정상 동작하지 않는 문제가 생겼다.
문제의 코드 : deviceOrientation = UIApplication.shared.statusBarOrientation
var deviceOrientation: UIInterfaceOrientation!
////////////////////////////////////////////////////////////////
if #available(iOS 13.0, *) {
guard let interfaceOrientation = UIApplication.shared.windows.first(where: { $0.isKeyWindow })?.windowScene?.interfaceOrientation else { return nil }
deviceOrientation = interfaceOrientation
} else {
// Fallback on earlier versions
deviceOrientation = UIApplication.shared.statusBarOrientation
}
// 또는 아래 코드도 사용했었는데 UIViewController의 방향을 확인 할 수 있긴하다.
// 위의 코드와 차이점이 뭐지 잘 모르겠다. 아시는분 댓글로 알려주세요. ㅜㅜ
if #available(iOS 13, *) {
deviceOrientation = vc.preferredInterfaceOrientationForPresentation
} else {
deviceOrientation = UIApplication.shared.statusBarOrientation
}
'Swift > UIViewController' 카테고리의 다른 글
[SWIFT]UIDocumentPickerViewController (0) | 2023.06.07 |
---|---|
[SWIFT]뷰 회전 관련 작업 : viewWillTransition (0) | 2023.04.24 |
[SWIFT]UIViewController SafeArea 영역 확인 (0) | 2023.04.17 |
[SWIFT]상위 UIViewController 가져오기 (0) | 2023.04.17 |
[SWIFT]UIStoryboard 확장 UIViewController 쉽게 불러오기 (0) | 2023.04.17 |