What is the difference between UIDevice orientation and UIInterface orientation ?
UIDevice orientation:-
[[UIDevice currentDevice] orientation]
UIInterface orientation:-
[[UIApplication sharedApplication] statusBarOrientation]
Moving on, the UIDeviceOrientation is the current orientation of the device itself, not of the user interface currently displayed within the device. UIInterfaceOrientation, on the other hand, is the current orientation of the target interface.
But sometimes, especially when dealing with legacy or old style code, or sometimes poorly designed code which you cannot easily redesign or refactor, you will need to rely on UIDeviceOrientation to determine the current orientation. An example of such poorly designed code is when you have a UIView which handles its own rotation.
Orientation is the process done immediately after an employee joins to make them aware of the company culture and the work they need to do. It can last up to a week or month. Onboarding, on the other hand, is a thorough process lasting upto three months or a year.
caseLandscapeLeft// Device oriented horizontally, home button on the right caseLandscapeRight// Device oriented horizontally, home button on the left caseFaceUp// Device oriented flat, face up caseFaceDown// Device oriented flat, face down while UIInterfaceOrientation has 5 possible values. Objective-C
The device orientation is the orientation the device is currently at. We can get the device orientation with this call:
[[UIDevice currentDevice] orientation]
This will return one of the following states: UIDeviceOrientationUnknown UIDeviceOrientationPortrait UIDeviceOrientationPortraitUpsideDown UIDeviceOrientationLandscapeLeft UIDeviceOrientationLandscapeRight UIDeviceOrientationFaceUp UIDeviceOrientationFaceDown
There are two states FaceUp and FaceDown. One of these will be returned when the device lays flat on a table. So when this is the case, we don't know how to layout our UI.
The trick is to get the UIInterfaceOrientation of the status bar. As we want our GUI to be at the same orientation as the status bar. To get the UIInterfaceOrientation from the statusbar we use this code:
[[UIApplication sharedApplication] statusBarOrientation]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With