Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - Screen Rotation?

What's the difference between UIDeviceOrientation & UIInterfaceOrientation ?

Which one should I use to detect rotation on a UIView?

like image 430
aryaxt Avatar asked Feb 05 '26 06:02

aryaxt


2 Answers

UIDeviceOrientation gives you information about the physical device itself while UIInterfaceOrientation tells you about the orientation of the views it is displaying. These do not need to match; when a user uses the orientation lock or if the the device orientation is face up.

You probably want to be checking UIInterfaceOrientation and the rotation methods on UIViewController to determine when views have been or should be rotated.

like image 52
Jonah Avatar answered Feb 06 '26 20:02

Jonah


UIDeviceOrientation refers to the physical orientation of the device whereas UIInterfaceOrientation refers to the orientation of the user interface.

So what you need to set is the autoResizeMask so that the view is resized correctly when its superview is resized. Set flexibleWidth and flexibleHeight for the view. Check http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIDevice_Class/Reference/UIDevice.html

Also - refer to

UIDEVICE orientation

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]
like image 21
Garrett Smallwood Avatar answered Feb 06 '26 20:02

Garrett Smallwood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!