views:

1714

answers:

8

I have an iPad app that works correctly except for an odd issue during launch. I've read several questions & answers regarding orientation, but this still has me stumped.

The root view controller is a UITabBarController with 3 tabs. Two of the tabs are have custom view controllers (one based off of UIViewController, the other off of UITableViewController) and both suffer from this launch orientation problem. The third tab is a custom UITableViewController that's embedded in a UINavigationController.

OK, here's the problem. If I start the app in Portrait orientation, everything works great. If I start it in Landscape orientation, the 3rd tab works perfectly. However, the first 2 tabs come up in Portrait orientation, even though:

  1. The status bar orientation correctly shows as landscape (spread across the screen).
  2. The Tab Bar view correctly shows as landscape with the tabs centered.
  3. All views return YES for shouldAutorotateToInterfaceOrientation for all orientations.

If I call [self interfaceOrientation] or [[UIApplication sharedApplication] statusBarOrientation] in the view controller's viewWillAppear, then the 3rd tab's view controller reports 3 (landscape) but the first two view controllers report 1 (portrait) even though the status bar is clearly landscape!

If I rotate the iPad to portrait and back to landscape, then all 3 tabs' views rotate correctly (and the methods above return 3, as expected).

Also, if I tap on any other tab and then back on tab #1 or #2, then they will now rotate correctly, even without rotating the iPad itself!

What am I missing?

+3  A: 

You have to add the supportedDeviceOrientations to your "myApp.plist" .

Click on this list, add the key "Supported interface orientations" and add the supported interface orientations. This solved the problem for me.

For further informationen follow this link and go to the section "The Application Bundle": http://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/CoreApplication/CoreApplication.html

paskster
Thanks, but I already have "Supported interface orientations (iPad)" with 4 values and "Supported interface orientations" with 1 value in my plist (the iPhone version can only be used vertically, but the iPad version works in any orientation). I don't see any reference to supportedDeviceOrientations, so I assume that was a typo?
Gorm
+1  A: 

I have the exact same issue and it's KILLING me. I have tried everything.

Adam
I feel your pain. Still haven't figured it out. Must be something simple we're doing wrong.
Gorm
When launching in landscape orientation detection is unreliable. However, if you launch in landscape, immediately after triggering didFinishLaunchingWithOptions it also triggers didRotateFromInterfaceOrientation for any NavigationController or TabBarController which is available to receive these events, and this will include the true orientation in the argument.I do a standard orientation detection inside didRotateFromInterfaceOrientation by using the status bar orientation (which is probably unreliable) and fix it immediately after in didRotateFromInterfaceOrientation if actually landscape.
Adam
A: 

This seems to be an issue with the SDK. I've had the same problem since beta 1 of iOS 3.2. If anyone know how to fix this, please let us know, there are many many people waiting for a solution.

DysonApps
A: 

I'm also watching for a solution for this problem.

Have you found any answers ?

William Remacle
+1  A: 

I finally found my answer: I just forgot this in my LoadingController.

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

just try this-
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

return (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown);
}

A: 

The solution is to add a key

UISupportedInterfaceOrientation

to you Info.plist with an array of strings specifying the suppored interface orientations at launch time, these are

  • UIInterfaceOrientationPortrait
  • UIInterfaceOrientationPortraitUpsideDown
  • UIInterfaceOrientationLandscapeLeft
  • UIInterfaceOrientationLandscapeRight

However, there is the follwing issue which may lead to confusion: At least with SDK 3.2 and iPad Simulator from XCode 3.2.4 I found that (at least some) Info.plist settings appeared to be cached and/or are not updated when installing the app. That is, adding the key above and installing and launching the app in the simulator had no effect. However, deleting the app from the simulator fixed the problem an the newly installed app behaved as specified.

Christian Fries
A: 

Even I got the same problem.Could anyone help me to resolve this isssue.

Srinivas G