【发布时间】:2012-07-24 19:37:41
【问题描述】:
UIDeviceOrientation 和 UIInterfaceOrientation 有什么区别?
我应该使用哪一个来检测 UIView 上的旋转?
【问题讨论】:
标签: iphone ios uiinterfaceorientation uideviceorientation
UIDeviceOrientation 和 UIInterfaceOrientation 有什么区别?
我应该使用哪一个来检测 UIView 上的旋转?
【问题讨论】:
标签: iphone ios uiinterfaceorientation uideviceorientation
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]
【讨论】:
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation] 或者应该是UIInterfaceOrientation orientation = self.interfaceOrientation,其中self 是一个UIViewController。