Reputation: 669
How can i get the device orientation in applicationDidFinishLaunching() method. I have tried UIDevice deviceorientation and StatusbarOrientaion. Both returns incorrect values (same orientation value irrespective of the current orienation).
Basically, I'm trying to load an image based on the device orientation till the app(webview) completes loading. So i thought i can determine the current orientation here and load an appropriate image (out of 4 images, one for each orientation).
BTW, I have added the supported interface orientations in the plist file.
Please let me know if you require any other information for you to properly address this question.
Thanks
Upvotes: 1
Views: 3559
Reputation: 4063
I'm using [[UIApplication sharedApplication] statusBarOrientation]
based on this post: http://www.ddeville.me/2011/01/getting-the-interface-orientation-in-ios/
Is that what you tried that you said didn't work? I had trouble with [[UIDevice currentDevice] orientation]
, but the status bar did the trick -- though not in applicationDidFinishLaunching
. I'm using it in the rotation callback method, which gets called immediately afterwards anyway. (And the callback appears to get called twice back-to-back at application startup, the first time with the incorrect UIDeviceOrientationPortrait
and the second time with the correct orientation.)
Upvotes: 0
Reputation: 4971
The value of UIDevice orientation is invalid until you call beginGeneratingDeviceOrientationNotifications
Have you called this first?
Upvotes: 1