Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Interface Orientation and Device Orientation?

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

like image 996
user3526002 Avatar asked May 03 '14 06:05

user3526002


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.

like image 149
Bill Abrams Avatar answered Sep 22 '22 12:09

Bill Abrams


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

like image 39
iPatel Avatar answered Sep 22 '22 12:09

iPatel