iPhone - Screen Rotation?

南楼画角 提交于 2019-12-30 07:25:16

问题


What's the difference between UIDeviceOrientation & UIInterfaceOrientation ?

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


回答1:


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.




回答2:


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]


来源:https://stackoverflow.com/questions/6838706/iphone-screen-rotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!