What's the Difference between Interface Orientation and Device Orientation? Both of them seems the same but what's the actual difference between them?
2 Answers
Interface Orientation can be anything, regardless of device orientation. Device Orientation is the actual physical orientation of the device you are holding, and this is not variable; it is what it is. If you are holding in Portrait, it is Portrait. But just because the device is in Portrait doesn't mean your interface is also in portrait. You may require your app to only provide landscape orientation, hence the interface orientation would be different than the device orientation.

- 320
- 2
- 9
-
When choosing orientation in the settings of a project, why are the possible orientations labelled as _Device Orientation_, when they are clearly referring to `UIInterfaceOrientation` here and not to `UIDeviceOrientation`? – Maxi Mus Sep 14 '16 at 12:41
-
Btw your answer would be even better if you explained why left and right are switched in the enumeration. Is this just a custom so people can tell the interface orientation from where the home button is, or is there a mathematical reason? – Maxi Mus Sep 14 '16 at 14:43
Following description got from this site.
UIDeviceOrientation is a property of the UIDevice class, and there are these possible values:
UIDeviceOrientationUnknown
- Can't be determinedUIDeviceOrientationPortrait
- Home button facing downUIDeviceOrientationPortraitUpsideDown
- Home button facing upUIDeviceOrientationLandscapeLeft
- Home button facing rightUIDeviceOrientationLandscapeRight
- Home button facing leftUIDeviceOrientationFaceUp
- Device is flat, with screen facing upUIDeviceOrientationFaceDown
- Device is flat, with screen facing down
As for UIInterfaceOrientation, it is a property of UIApplication and only contains 4 possibilities which correspond to the orientation of the status bar:
UIInterfaceOrientationPortrait
=UIDeviceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
=UIDeviceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
=UIDeviceOrientationLandscapeRight
UIInterfaceOrientationLandscapeRight
=UIDeviceOrientationLandscapeLeft
(copied from docs)
For example, the device (the actual iPhone or iPod) could be in UIDeviceOrientationLandscapeRight but if your app doesn't support that, it (your app) might still be in UIInterfaceOrientationPortrait.
In addition, to get UIDeviceOrientation, you use [[UIDevice currentDevice] orientation], and to get UIInterfaceOrientation, you use [[UIApplication sharedApplication] statusBarOrientation]