问题描述:

What I want is Portrait orientation for iPhone and Landscape orientation for iPad app.

My app is targeted for > ios5

I searched on web about this but got different answers but not the exact one.

网友答案:

So here is what I did

For iPhone

and for iPad

And for iPad controllers I added below code, this is not necessary for ios6 applications

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
            interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
网友答案:

You should be able to do this by simply adding this code to your app delegate.

Swift code:

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> Int {
    if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
        return Int(UIInterfaceOrientationMask.Portrait.rawValue)
    } else {
        return Int(UIInterfaceOrientationMask.LandscapeLeft.rawValue | UIInterfaceOrientationMask.LandscapeRight.rawValue)
    }
}
相关阅读:
Top