views:

394

answers:

2

I was curious to know if there is some way to determine the orientation of a screen on iPhone/iPad.

Currently I find myself setting a member variable when this message is called:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   self.orientation = interfaceOrientation;
   return YES;
}

... which feels like something I should be able to query as a state instead of having to track it when it changes.

+2  A: 

You can do [[UIDevice currentDevice] orientation].

Elfred
This is *not* the correct way for interface orientation. From the manual: "The orientation property uses these constants to identify the device orientation. These constants identify the physical orientation of the device and are not tied to the orientation of your application’s user interface."
Eiko
+1  A: 

UIViewController has the interfaceOrientation property.

Don't get confused by orientation in UIDevice, which is not the orientation of the interface, but the physical orientation.

Eiko
That is a subtle but important distinction. Thanks for the answer.
raiglstorfer