기존 프로젝트 코드에서 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
}
 

+ Recent posts