Is there any way to detect the screen orientation even when the user has locked his orientation? My App uses a custom camera view and I would like to be able to save images in either landscape or portrait depending on the orientation. I am currently using the following code to detect the orientation, however this only works if the user has not locked it.
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
let orientation: UIDeviceOrientation = UIDevice.current.orientation
switch (orientation) {
case .portrait:
print("Portrait")
case .landscapeRight:
print("Left")
case .landscapeLeft:
print("Right")
default:break
}
}
If this is not the correct way to work with the camera orientation, please guide me in the right direction.