How to check the orientation of device programmatically in iPhone?

Viewed 50943

Possible Duplicate:
iPhone orientation

How to check the orientation of device at any point off time programmatically in iPhone ?

Thank You.

6 Answers

Try it.

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

if ( ([[UIDevice currentDevice] orientation] ==  UIDeviceOrientationPortrait)  )
{
   // do something for Portrait mode
}
else if(([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) || ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft))
{
   // do something for Landscape mode
}
Related