0

I have an iOS app for an iPhone that displays information on the screen. The Deployment Info indicates that LandscapeLeft and LandscapeRight are supported.
When I start my app with the device in LandscapeRight, then everything is fine and turning my device to LandscapeLeft reverts my whole image by 180 degrees and the displayed information are still ok.
Now if I start the application with my device turning in LandscapeLeft, the the application will anyway start in Landscape Right and I have to do a full physical turn of my device to have the right orientation detected.
Basically if I add the code at the beginning of my ViewController viewDidLoad:

if ([UIApplication sharedApplication].statusBarOrientation == UIDeviceOrientationLandscapeLeft)
{
    NSLog(@"LandscapeLeft");
}
else  if ([UIApplication sharedApplication].statusBarOrientation == UIDeviceOrientationLandscapeRight)
{
    NSLog(@"LandscapeRight");
}

always displays LandscapeRight.

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration

is not called if my device orientation does not change physically. Any suggestion how I can detect the real orientation ? Thanks.

=== EDIT ===
I just found out something interesting. If I keep the Launchscreen in the .plist file (I removed it) and related default Launchscreen.xib, then it works fine. How can I properly have ;y desired behaviour without launch screen ?

Laurent Crivello
  • 3,809
  • 6
  • 45
  • 89

1 Answers1

0

you have to check you .plist file setting...

In your application’s "Info.plist" file, add the UISupportedInterfaceOrientations key with the UIInterfaceOrientationLandscapeLeft and UIInterfaceOrientationLandscapeRight values

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

For more information refer documentation link https://developer.apple.com/library/ios/technotes/tn2244/_index.html

Dipen Chudasama
  • 3,063
  • 21
  • 42
  • see this link..http://stackoverflow.com/questions/5888016/ios-device-orientation-on-load – Dipen Chudasama Jan 21 '15 at 12:46
  • Same issue :-( Added the shouldAutorotateToInterfaceOrientation function, but even if device is in LandscapeLeft, [UIApplication sharedApplication].statusBarOrientation indicates LandscapeRight. – Laurent Crivello Jan 22 '15 at 08:04