Reputation: 21
i want to fetch the current orientation of device. I have written this code in AppDelegate class : my code:
if (UIInterfaceOrientation.LandscapeLeft == (UIInterfaceOrientation)UIDevice.CurrentDevice.Orientation &&
UIInterfaceOrientation.LandscapeRight == (UIInterfaceOrientation)UIDevice.CurrentDevice.Orientation) {
//code
} else {
//code
}
UIDevice.CurrentDevice.Orientation is giving unknown?
Upvotes: 2
Views: 65
Reputation: 26495
Can you use the InterfaceOrientation
property of your UIViewController
?
That is probably a better value to check against, as it is the state in which your app is currently rotated and "allowed" to rotate to. Checking the UIDevice
might not match the rotation of your UI.
Upvotes: 1