Posts

Post not yet marked as solved
3 Replies
5.4k Views
Hi,Based on a condition, I forcefully display the view in portrait mode. For another condition, I want to display my app in landscape mode.I get the device orientation using let orientation = UIApplication.shared.statusBarOrientation var orientationValue = UIInterfaceOrientation.landscapeRight.rawValue if orientation == .landscapeLeft || orientation == .landscapeRight { orientationValue = orientation.rawValue } UIDevice.current.setValue(orientationValue, forKey: "orientation")What happens with this code is, after forcefully displaying portrait mode, the orientation becomes portrait and the orientationValue always remains landscape right as declared, even when the device is actually in landscape left orientation.I tried setting boolean variables to force display landscape or not, but in all cases, the if condition becomes false after forcefully displaying portrait mode.Any ways to get the device's actual orientation?
Posted Last updated
.