개발/iOS

[Orientation] BUG IN CLIENT OF UIKIT: Setting UIDevice.orientation is not supported. Please use UIWindowScene.requestGeometryUpdate(_:)

1n년차 회사원 2023. 3. 15. 16:04

        if let appDelegate = UIApplication.shared.delegate as? AppDelegate {

            appDelegate.shouldSupportAllOrientation = false

            if #available(iOS 16.0, *) {

                let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene

                windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: .portrait))

            } else {

                UIDevice.current.setValue(Int(UIInterfaceOrientation.portrait.rawValue), forKey: "orientation")

            }

        }

참고 : https://stackoverflow.com/questions/73124396/is-force-view-controller-orientation-working-in-ios-16-beta