【发布时间】:2011-10-15 18:03:50
【问题描述】:
我有一个UIView 类,我将它添加到我的主UIViewController 中,我需要在应用程序启动时检查设备(iPad)的方向,在viewDidLoad 方法中。但是因为类是UIView(不是UIViewController),所以我不能使用willAnimateRotationToInterfaceOrientation等方法。
所以我尝试在我的UIView 课程中使用它:
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {
但是,使用一些断点进行测试,无论方向是什么,of 语句都不会被调用,它的跳过正确地通过了它。那么你建议我做些什么来克服这个问题?
我需要从 UIView 类中检测方向。
谢谢。
【问题讨论】:
标签: objective-c ipad uiview orientation