UIDeviceOrientation
& 和有什么不一样UIInterfaceOrientation
?
我应该使用哪一个来检测 UIView 上的旋转?
UIDeviceOrientation
& 和有什么不一样UIInterfaceOrientation
?
我应该使用哪一个来检测 UIView 上的旋转?
UIDeviceOrientation
为您提供有关物理设备本身的信息,同时UIInterfaceOrientation
告诉您它正在显示的视图的方向。这些不需要匹配;当用户使用方向锁定或设备方向朝上时。
您可能想要检查UIInterfaceOrientation
和旋转方法UIViewController
以确定视图何时已旋转或应该旋转。
UIDeviceOrientation
指的是设备的物理方向,而UIInterfaceOrientation
指的是用户界面的方向。
所以你需要设置的是 autoResizeMask 以便在调整其父视图大小时正确调整视图大小。为视图设置flexibleWidth 和flexibleHeight。检查http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIDevice_Class/Reference/UIDevice.html
另外 - 参考
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]