Search code examples
iosswiftxcode6device-orientation

Set device orientation as landscape for iPad only


I want landscape left and landscape right to be allowed on the iPad only, and not on the iPhone. How should I do this? Thanks in advance.


Solution

  • Modify your info.plist file to have entries that look something like this:

    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    

    More information about those keys can be seen in this Apple documentation and I worked up the answer by looking at this public repo's info.plist file (though it's from iOS 3.2, I did try it out on sample project and it seems to still work fine).