What is the difference between UIDevice orientation and UIInterface orientation ?
UIDevice orientation:-
[[UIDevice currentDevice] orientation]
UIInterface orientation:-
[[UIApplication sharedApplication] statusBarOrientation]
What is the difference between UIDevice orientation and UIInterface orientation ?
UIDevice orientation:-
[[UIDevice currentDevice] orientation]
UIInterface orientation:-
[[UIApplication sharedApplication] statusBarOrientation]
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]