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
However, when I use the General checkbox in Xcode, the Info.plist
file says the opposite:
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
UIDevice.orientationDidChangeNotification
in rootViewController and it gets triggered 3 times. "right" "left" "left" when starting simulator. gonna try physcial device and see if I reproduce this. – AdversityviewWillTransition(to:with:)
to look at orientations, but didn't look at the Notifications. To get the orientation programmatically, at any time (not just transitions) I have a button on the screen that just printsUIDevice.current.orientation
to the console. – FellUISupportedInterfaceOrientations
array has the one valueUIInterfaceOrientationLandscapeLeft
. Contradiction between Xcode and API remains. – FellUISupportedInterfaceOrientations~ipad
. I am in the habit of renaming the first key with a~iphone
suffix. – FellUIDevice.current.beginGeneratingDeviceOrientationNotifications()
. – Fell