user1960854
user1960854

Reputation: 21

Need to resolve issue related to orientation in MonoTouch

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

Answers (1)

jonathanpeppers
jonathanpeppers

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

Related Questions