Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between UIDevice orientation and UIInterface orientation?

Tags:

ios

What is the difference between UIDevice orientation and UIInterface orientation ?

UIDevice orientation:-

    [[UIDevice currentDevice] orientation]

UIInterface orientation:-

    [[UIApplication sharedApplication] statusBarOrientation]
like image 547
Mayank Avatar asked Oct 20 '15 18:10

Mayank


People also ask

What is the difference between uideviceorientation and UI interface orientation?

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.

Why do we need uideviceorientation?

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.

What is the difference between onboarding and orientation?

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.

What is the difference between uiinterfaceorientation and caselandscapeleft and casefacedown?

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


1 Answers

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]
like image 135
Subin Avatar answered Nov 13 '22 10:11

Subin