Swift - Allow Rotation on iPad Only

后端 未结 5 867
小鲜肉
小鲜肉 2020-12-13 01:51

How could I allow my universal app written in Swift on iOS 8.3 SDK to support only portrait mode on iPhone, but both portrait and landscape mode on iPad?

I know in t

5条回答
  •  无人及你
    2020-12-13 02:39

    I'm not sure if Chris's answer works by just copying and pasting "Supported Interface orientations (iPad)" key; probably not judging from the XML source of info.plist. for achieving different orientation support. you can open the info.plist XML source and edit it as follows:

    UISupportedInterfaceOrientations
    
        UIInterfaceOrientationPortrait
    
    
    
    UISupportedInterfaceOrientations~ipad
    
        UIInterfaceOrientationPortrait
        UIInterfaceOrientationPortraitUpsideDown
        UIInterfaceOrientationLandscapeLeft
        UIInterfaceOrientationLandscapeRight
     
    

    And there is an easeir approche from xcode UI. Go to your project settings. select your target in the "General" tab and then in "Deployment Info" section you can first select iphone/ipad and mark the device orientations you want to support for each device sepratly and then change the devices to "Universal". it will generate the above xml under the hood.

    the "Universal" option here shows the selections that are common between iPhone and iPad.

提交回复
热议问题