views:

761

answers:

4

Hello,

I have recently run into a problem. My iPad app is somehow preventing the iPad from auto-rotating. My app loads a UISplitView with both of the view controllers returning YES for shouldAutorotateToInterfaceOrientation:. I have set up my info.plist to include the "Supported interface orientations" key with all four orientations. When I run the app, however, rotating the device does not rotate the splitView (even though I am receiving UIDeviceOrientationDidChangeNotification). In addition, when I exit my app in a different orientation that it started in the iPad home screen doesn't autorotate to the correct view until I rotate it again without my app running.... Any Ideas would be much appreciated....

A: 

You said that your first Problem is, that the UISplitView prevents you from autorotating. Try to use a Subclass of Splitview instead that enbales autorotating:

@implementation SplitViewControllerRotating - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ NSLog(@"SplitViewControllerRotating shouldAutorotate"); return YES; } @end

Your second Problem sounds weired. You said after exiting your app you have to rotate, so that your iPad recognizes interface-orientation. Cant help you with that.

paskster
I gave it a shot... It didn't work... Isn't the purpose of the UISplitView to autorotate anyway?
Michael
A: 

I had the same problem right now. The reason was that I had accidentally added another view to the window in addition to UISplitViewController's view. Removing the extra view made it work.

nschum
+1  A: 

Is your UISplitViewController set as your root view controller? If not, that may be the cause of your problem. I was having a similar issue - the status bar would rotate but my detail and master views would stay in place. I rearranged the views so that the UISplitViewController was the root and then my 'main menu' was presented as a modal view controller on top of the split view, and it made the rotation problem go away.

According to the iPad Programming Guide, "The split view controller’s view should always be installed as the root view of your application window."

Hope this helps.

Erik Asmussen
+1  A: 

UISplitViewController is one of the most temperamental view controller subclasses I've ever had to use. In order for it to work "perfectly", it must exist as a single root view in your application's window. You can, however, get around this with some trickery -- in my case, I needed a UITabBarController with at least two distinct UISplitViewControllers as view controllers -- but then you have to take care of weird cases involving rotation and UISplitViewControllerDelegate callbacks not firing.

Here's hoping that Apple makes UISplitViewController more compatible with other UIKit components in the future...

LucasTizma

related questions