开发者

UIDeviceOrientationDidChangeNotification doesn't work while device is on table?

Hi there i have a problem, In my AppDelegate i have used method beginGeneratingDeviceOrientationNotifications to start notify me when device starts rotating. It works fine if i hand-held my ipad but when it is kept on table it doesn't work as expected. it fires UIDeviceOrientationUnknown notification. Also this notification gets started after UI launches not on splash screen.

following is my code:

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];

then some where i launches my UI as

[self Launch_UI];

but notification starts responding after [开发者_Python百科self Launch_UI]; call even if notification is registered before its call...

Please any help is appreciable!!!


When you place your device on a table, [[UIDevice currentDevice] orientation] will return UIDeviceOrientationFaceUp. Then if your device remains sitting on the table face up, it doesn't matter how you rotate it on the table, the current device orientation will still be UIDeviceOrientationFaceUp.

If the device has issues determining the orientation, you may get UIDeviceOrientationUnknown. See this tutorial on how to handle device rotation using UIDeviceOrientationDidChangeNotification.

Regarding your notification only firing after the UI is loaded, the UIDeviceOrientationDidChangeNotification will only fire when the device is rotated. So if you are not rotating your device until after the UI loads, you wont get a notification. If this is not the cause of the issue, I'd have to see more of your code to have a better idea of what is going on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜