【发布时间】:2012-11-10 15:33:39
【问题描述】:
我使用通知来获取设备的方向。
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[notificationCenter addObserver:self
selector:@selector(deviceOrientationDidChange)
name:UIDeviceOrientationDidChangeNotification
object:nil];
但是当设备的屏幕旋转被锁定时,不会调用选择器函数。有什么帮助吗?
【问题讨论】:
-
“notificationCenter”设置正确吗?检查它是否不为零。你也可以试试这个语法:[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil];
-
你知道怎么做吗?我已经通过 XCode 锁定了方向,但使用
UIDevice.current.orientation给出了解锁方向。即使设备实际上处于横向左侧。
标签: iphone objective-c ios device