Question

What's the Difference between Interface Orientation and Device Orientation? Both of them seems the same but what's the actual difference between them?

Was it helpful?

Solution

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.

OTHER TIPS

Following description got from this site.

UIDeviceOrientation is a property of the UIDevice class, and there are these possible values:

  • UIDeviceOrientationUnknown - Can't be determined
  • UIDeviceOrientationPortrait - Home button facing down
  • UIDeviceOrientationPortraitUpsideDown - Home button facing up
  • UIDeviceOrientationLandscapeLeft - Home button facing right
  • UIDeviceOrientationLandscapeRight - Home button facing left
  • UIDeviceOrientationFaceUp - Device is flat, with screen facing up
  • UIDeviceOrientationFaceDown - 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]

More info

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top