Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Landscape Left vs Right vs Wrong

TL;DR: The iOS docs disagree with Info.plist about which orientation (landscape left vs. right) has the home button on which side. Am I missing something? (For example, there is a distinction between what orientation the code thinks it is in, and the orientation the device knows it is in. See next-to-last bullet point labeled ❓ below.)

The doc for UIDeviceOrientation says

screenshot from docs

However, when I use the General checkbox in Xcode, the Info.plist file says the opposite:

screenshots from Xcode

The above info presents the contradiction clearly enough. My question is: am I missing something or should I just take this as long-lasting cruft in the toolchain/docs/API?


What actually happens when the app runs on the Simulator or devices, you ask? The following is a subset of the data I have collected. For your reading convenience, I have emphasized the terms LEFT and RIGHT. Your brain may still explode.

There are three quantities to track:

  • What Xcode/plist say
  • What the Simulator menu items say [or what device orientation is]
  • What the API call UIDevice.current.orientation says.

When the General checkbox is set solely to "Landscape LEFT":

  • The Info.plist file says "Landscape (LEFT home button)" [i.e. disagrees with documentation]
  • The Simulator launches
    • with screen image up-side-up [i.e. correctly]
    • with Hardware > Orientation menu item "Landscape RIGHT" checked [i.e. disagrees with Xcode/plist]
    • with home button on LEFT [i.e. relation between menu item and home button location agrees with docs]
  • UIDevice.current.orientation == .landscapeRIGHT [i.e. disagrees with Xcode, but agrees with Simulator menu]
  • Choosing menu item Hardware > Orientation > Landscape LEFT
    • flips the screen image to upside-down [correct behavior: no image auto-rotate]
    • puts home button on RIGHT [of course]
    • UIDevice.current.orientation == .landscapeLEFT [consistent with docs/contrary to Xcode/plist]
  • Launching iPhone with home button on LEFT:
    • shows screen image correctly
    • UIDevice.current.orientation == .landscapeRIGHT [consistent with docs/contrary to Xcode/plist]
  • Rotating the phone 180°
    • puts home button on RIGHT [of course]
    • UIDevice.current.orientation == .landscapeRIGHT [i.e. it's consistent with what the app thinks is going on, not with the physical orientation of the device]
  • iPad behaves same as iPhone
like image 913
Andrew Duncan Avatar asked Mar 13 '19 19:03

Andrew Duncan


1 Answers

I think mainly it's a matter of a contradiction between Xcode UI and info.plist. Xcode UI shows "Device Orientation", while info.plist speaks about "Supported Interface Orientation". But as we know those two are different things, so there's definitely something wrong there.

Assuming, between the two, that info.plist wins then those fields (for iPhone and iPad) are used to specify Supported Interface Orientation. I.e. the same option that you can also override in a specific view-controller through supportedInterfaceOrientations.

Instead the referenced doc page is about Device Orientation, with its own definition of what is landscapeLeft: home button to the right.

Now, looking at Interface Orientation Mask docs, there's no real detail on what is landscapeLeft, but old Xcode UI screenshots show that home button is to the left. See e.g. from this SO thread:

enter image description here

EDIT: Interface Orientation doc page instead has detail on what is landscapeLeft: home button to the left, as shown in old screenshots.

Conclusions

So, all in all, it seems to me that:

  1. Xcode UI/info.plist are about supported interface orientation, which has its own definition of landscape left/right

  2. Device orientation has the opposite definition of landscape left/right

like image 77
superjos Avatar answered Oct 20 '22 22:10

superjos