Launch Landscape App for iPad

Facing one issue with launching the app in landscape orientation for the iPad. I developed the iPhone app, which I later ported to the iPad.

I made a setting regarding orientation in info.plist

[ UISupportedInterfaceOrientations~ipad ] to support all orientation UIInterfaceOrientationPortrait , UIInterfaceOrientationPortraitUpsideDown , UIInterfaceOrientationLandscapeLeft , UIInterfaceOrientationLandscapeRight. 

but when I launch the iPad application in landscape mode, it always starts in potrait mode.

Along this

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } 

help me if I missed something with this.

Thanks,

Sagar

+6
iphone ipad
source share
4 answers

here is something that I also found: setting the initial interface orientation in your info.plist is ignored if you have Supported interface orientations configured with a different orientation in the first slot! Put your initial orientation there - and the simulator will start correctly, like the application. it galoshed me for a long time!

+10
source share

Put the UISupportedInterfaceOrientations in your -Info.plist with a setting for each orientation you support. This is used to see which orientation the application can start with. Then he will ask your controllers.

+9
source share

Sagar - I had the same problem, but I was able to solve it.

Like yours, my application was launched as an application for the iPhone, which I “upgraded” to a universal application using the Xcode wizard. I noticed that when starting on the iPad itself, starting from the landscape, the application will launch in “Portrait”, and then, possibly, turn it into “Landscape”. On the simulator, starting with the landscape, the application will start in the Landscape, then the simulator will be placed in the "Portrait".

On iPad, my app is an advanced viewing app with TabBarControllers left and right. Each tab is a view controller that returns YES in order to activate the I / O attribute.

I noticed that the brand new wizard-created simple case with the splitviewcontroller Universal did not have this problem.

The difference I found between my application and the simple case was that I did not add the splitview-controller view to the application window in applicationDidFinishLaunchingWithOptions. Instead, at this point, I showed the download view, and then when the initialization thread has finished, I add the splitviewcontroller view (and hide the load view).

When I added the splitviewcontroller view to the application window while calling applicationDidFinishLaunchingWithOptions, everything started to work fine.

There must be some magic that happens when returning from applicationDidFinishLaunchingWithOptions ???

Is your application similar to mine because it does not add the view of the main view controller to the window during applicationDidFinishLaunchingWithOptions?

+5
source share

As indicated in a number of posts, you should configure info.plist with both supported and initial interface orientation. However, the bigger the problem, when the initial orientation becomes effective? The answer is NOT when your view controller receives the message "viewDidLoad". I found that on an iPad-1 running iOS 5.0, the requested initial orientation only becomes effective after a few “shouldAutorotateToInterfaceOrientation,” (this message passes the UIInterfaceOrientation parameter to the receiver.) Also, even if the orientation says it's in landscape mode, it may not be so! The only way to make sure that the view is in landscape mode is to check that the height of the view is less than the width of the view. The strategy that worked for me was to lay out the subview that I wanted when the message "viewDidLoad" was received, but to delay the actual addition of these subviews to the view until the controller received a valid message "shouldAutorotate .." with orientation set to "Landscape" Mode. The code looks something like this:

 (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations // NB Even when the interface orientation indicates landscape mode // this may not really be true. So we insure this is so by testing // that the height of the view is less than the width if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) { CGRect viewBounds = [[self view] bounds]; if ( viewBounds.size.height < viewBounds.size.width ) [self addMySubViews]; return YES; } else return NO; } 

Apple has just released iOS 5.1, so this behavior may change. But I expect the code that is here should still work.

+1
source share

All Articles