Different Initial interface orientation iPhone and iPad universal application

后端 未结 2 1950
长发绾君心
长发绾君心 2020-12-22 06:18

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 answ

2条回答
  •  再見小時候
    2020-12-22 07:05

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

提交回复
热议问题