我想知道我设备的当前方向。
if([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait)
{
}
但这行不通
最佳答案
您应该像这样启用设备方向通知:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]
然后可以查询当前方向
编辑:
来自文档:“除非通过调用 beginGeneratingDeviceOrientationNotifications
启用方向通知,否则此属性的值始终返回 0”(其中 0 是 UIDeviceOrientationUnknown
)
关于iphone - 当前设备的 UIInterfaceOrientation 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10715266/