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:
- The status bar orientation correctly shows as landscape (spread across the screen).
- The Tab Bar view correctly shows as landscape with the tabs centered.
- 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?