Different Initial interface orientation iPhone and iPad universal application

后端 未结 2 1949
长发绾君心
长发绾君心 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)
        }
    }
    
    0 讨论(0)
  • 2020-12-22 07:10

    So here is what I did

    For iPhone enter image description here

    and for iPad enter image description here

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

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
                interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    }
    
    0 讨论(0)
提交回复
热议问题