What's the Difference between Interface Orientation and Device Orientation? Both of them seems the same but what's the actual difference between them?
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.
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]
© 2022 - 2024 — McMap. All rights reserved.
UIInterfaceOrientation
here and not toUIDeviceOrientation
? – Variegated