Glasswing
Glasswing

Reputation: 43

Launching an app in landscape under ios6 while supporting all orientations

I have done a ton of research and am still unable to find a solution for this...

I have an app that supports all orientations. When the app is run on the iPad I want it to launch in landscape mode. The user can then rotate to portrait if they choose. Under ios5, I accomplished this by setting supported orientations for the iPad in the info.plist file to lansdcape left. I then used the shouldAutorotateToInterfaceOrientation method in each view controller to allow all orientations when the app was running.

I then changed my code to support the new orientation methods for iOS6 but when I ran the app on the iPad, it was not rotating at all. I then changed the info.plist file to support all orientations for the iPad. This solved the problem with the iPad not autorotating but now I can't figure out how to force the app to initially open in landscape mode. Any ideas?

Thanks in advance for any help you can give!

Upvotes: 2

Views: 603

Answers (1)

ChrisH
ChrisH

Reputation: 4558

I ran into something similar recently, although my problem was that I wanted to force portrait in an iPhone app, but allow movies to play in landscape. Here's what I did:

Add a property to my app delegate to store the orientations I want to allow:

@property (nonatomic, assign) NSUInteger supportedOrientations;

Then in the app delegate, implemented the new iOS 6 method:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

    return supportedOrientations;
}

On app launch I forced portrait:

self.supportedOrientations = UIInterfaceOrientationMaskPortrait;

And then once the app had finished launching and I'd shown my root view controller, I set it to support both orientations:

self.supportedOrientations = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;

I had to add the additional step of subclassing my UINavigationController to prevent rotation after that, because I wanted to allow landscape video but not rotation:

- (BOOL)shouldAutorotate {

    return FALSE;
}

But that's just for info. You won't need that

Upvotes: 1

Related Questions