当锁定在外部设置时,如何检测iPad iOS 9 上的设备方向更改事件



在iPad iOS 9 上,带有Objective-C: - 将方向锁定在应用程序外 - 代码:如何检测设备何时更改方向?

我尝试了所有可能性:

1)尝试捕获 uideViceOrientationDidchangenotification 事件:

- (void)subscriptientationChangeEvent {    [[UIDEVICE CurrentDevice] begingeneratingDeviceRientationNotifications];    [[nsnotificationcenter defaultCenter] addobserver:self                                             选择器:@Selector(entientationChanged :)                                                 名称:uideViceorientationDidchangenotification                                               对象:[Uidevice CurrentDevice]];} - (void)entientationChanged :( nsnotification *)注意{     NSLOG("设备旋转");}

2)覆盖 viewWillTransitionTosize 方法

- (void)viewWillTransitionTosize :( cgsize)size withTransitionCoordinator:(id)协调员{    [Super ViewWillTransitionTosize:size withTransitionCoordinator:协调员];    NSLOG("设备旋转");}

3)使用kVo查看的值 eartientation [uidevice currentDevie]

4)使用KVO查看的值 statusbarorientation [uiapplication sharedApplication]

5)SET 需要全屏幕设置 statusbarstyle

参考:链接

应用此设置并与上述所有尝试结合在一起,但都失败了。

6)使用加速度计(CMMOTIONMANAGER)

有建议吗?非常感谢

如果设备方向锁定;您的应用程序必须遵守它。出于明显的原因,您将无法检测到取向。所以简短的答案是你不能。

最新更新