How do I disable landscape-orientation on an iPad app?

后端 未结 8 1328
臣服心动
臣服心动 2021-02-01 12:41

I created a completely new, single-view iOS universal Swift app. Then, I unchecked \"Landscape Left\" and \"Landscape Right\" in the app settings. I ran it on my iPhone, and hoo

相关标签:
8条回答
  • 2021-02-01 13:01

    Its work perfectly. Dont need to write code for it.

    First select project and then go in first tab "General".

    Now select "Devices" option in Deployment info section is iPad and in that down select Device orientation .. In which remove checkmark from landscape Left, Right option

    After done select it back device as universal and set device orientation as portrait..mode and remove check mark from landscape mode.

    Now run your app in iPad and check that things. I hope it will be resolved.

    0 讨论(0)
  • 2021-02-01 13:09

    In Xcode 10 at least, for a universal app this feature is broken. For a universal app setting the orientation restriction by checking the relevant orientation only works for iPhone, you will need to go into the plist and remove the unwanted orientations under "Supported interface orientations (iPad)", where you will find all four orientations awaiting you regardless of what you checked. It's simply a bug in Xcode that apparently doesn't have a very high priority since it's been around for a while.

    0 讨论(0)
  • 2021-02-01 13:12

    This image is enough, only select the Portrait.


    edit for Shyam's comment

    Xcode8.3.3 MacOS Sierra v10.12.5

    0 讨论(0)
  • 2021-02-01 13:17

    these process of override does not work now.. and only changing the UI supported interface oriatations for ipad in info.plist will only temporarily solve the problem but will create problem when you will go for app validation and app sumbmission to app store.. For successfully validating and submitting you have to also add the key

    "UIRequiresFullScreen"

    you have to modify the keys like this..

    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <true/>
    

    I have tested this...

    0 讨论(0)
  • 2021-02-01 13:19

    xCode 11

    project ----> General -----> Devices ---->iPad

    0 讨论(0)
  • 2021-02-01 13:21

    There are separate entries in Info.plist for iPhone and iPad supported orientations.

    • iPhone = UISupportedInterfaceOrientations
    • iPad = UISupportedInterfaceOrientations~ipad

    You need to modify Info.plist and remove landscape entries for UISupportedInterfaceOrientations~ipad key.

    0 讨论(0)
提交回复
热议问题