emachine
emachine

Reputation: 1163

How do I check the orientation of the device?

I'm looking for a quick way to tell if the device is being held with the home button to the right or to the left. Is there a function to do so?

Upvotes: 2

Views: 2549

Answers (1)

Eric
Eric

Reputation: 3895

Look at the UIDevice documentation. There is an orientation property available. Something like:

UIDeviceOrientation d = [[UIDevice currentDevice] orientation];

The values of d you are looking for are:

UIDeviceOrientationLandscapeLeft - The device is in landscape mode, with the device held upright and the home button on the right side.

UIDeviceOrientationLandscapeRight - The device is in landscape mode, with the device held upright and the home button on the left side.

Upvotes: 7

Related Questions