1

嗨,我有一个问题,在我的设备开始旋转时,我AppDelegate使用beginGeneratingDeviceOrientationNotifications了开始通知我的方法。如果我手持 ipad,它可以正常工作,但是当它放在桌子上时,它不能按预期工作。它会触发UIDeviceOrientationUnknown通知。此通知也会在 UI 启动后启动,而不是在启动画面上。

以下是我的代码:

if([[[PulseUIFactory Factory] GetUICreator] IsIPad])
    {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
    }
     current device stars giving proper values.
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

然后在我启动我的用户界面的地方

[self Launch_UI];

但是通知在[self Launch_UI];通话后开始响应,即使通知在其通话之前已注册...

请任何帮助都是可观的!!!

4

1 回答 1

0

当您将设备放在桌子上时,[[UIDevice currentDevice] orientation]将返回UIDeviceOrientationFaceUp. 然后,如果您的设备仍然正面朝上放在桌子上,无论您如何在桌子上旋转它,当前设备方向仍然是UIDeviceOrientationFaceUp.

如果设备在确定方向时遇到问题,您可能会得到UIDeviceOrientationUnknown. 请参阅教程,了解如何使用UIDeviceOrientationDidChangeNotification.

关于仅在加载 UI 后触发的通知,只会UIDeviceOrientationDidChangeNotification在设备旋转时触发。因此,如果您在 UI 加载后才旋转设备,您将不会收到通知。如果这不是问题的原因,我必须查看更多代码才能更好地了解正在发生的事情。

于 2013-05-13T00:32:45.203 回答