Fix orientation on iOS 16

This commit is contained in:
Arkadiusz Fal
2022-08-26 10:25:07 +02:00
parent 653cca07fe
commit fc7052a7fa
4 changed files with 20 additions and 6 deletions

View File

@@ -32,5 +32,17 @@ struct Orientation {
UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
UINavigationController.attemptRotationToDeviceOrientation()
if #available(iOS 16, *) {
guard let windowScene = SafeArea.scene else { return }
let rotateOrientationMask = rotateOrientation == .portrait ? UIInterfaceOrientationMask.portrait :
rotateOrientation == .landscapeLeft ? .landscapeLeft :
rotateOrientation == .landscapeRight ? .landscapeRight :
.allButUpsideDown
windowScene.requestGeometryUpdate(.iOS(interfaceOrientations: rotateOrientationMask)) { error in
print("denied rotation \(error)")
}
}
}
}