Different Initial interface orientation iPhone and iPad universal application

牧云@^-^@ 提交于 2019-12-18 09:45:09

问题


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.


回答1:


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);
}



回答2:


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)
    }
}


来源:https://stackoverflow.com/questions/17628667/different-initial-interface-orientation-iphone-and-ipad-universal-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!