views:

148

answers:

3

Hi,

In my iPad app, I need to run some layout code to set the proper layout depending on the orientation. By default, the layout is configured for the landscape orientation, so in the case that the app starts in portrait mode, I need to take extra action to configure the views properly for display in portrait.

In my -application:didFinishLaunchingWithOptions: method, I check the orientation using [[UIDevice currentDevice] orientation]. The problem here is that it always returns portrait even if the app is starting in landscape. Is there any way around this?

+1  A: 

You want to make sure you set the proper keys in your Info.plist to allow for the orientations you want:

UISupportedInterfaceOrientations
    UIInterfaceOrientationPortrait
    UIInterfaceOrientationPortraitUpsideDown
    UIInterfaceOrientationLandscapeLeft
    UIInterfaceOrientationLandscapeRight
lucius
I have all 4 of the orientations in my plist file.
macatomy
A: 

Did you find an answer for this elsewhere? I have the same problem

cat
A: 

Use self.interfaceOrientation in your view controller - it's a property of UIViewController that is set by iOS for you, and in some cases is more reliable than [[UIDevice currentDevice] orientation].

Here's a detailed description: http://bynomial.com/blog/?p=25

Tyler