Question

In my application, supported orientations are Landscape Right & Landscape Left. Its single screen application. In ViewController I added following code to restrict orientation.

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

-(BOOL)shouldAutorotate
{
    return YES;
} 

My Problem is whenever app launches in Landscape Left. If device position Landscape Right, then app view rotate in 180 degree then app starts working in Landscape Right.

There is no issue if device position is Landscape Left.

Note: I am testing application on iPod 5.

EDIT:

After some observations, If you are supporting only Landscape (i.e Landscape Right & Landscape Left), then you will face this problem. Application will always open in orientation which listed first in plist (In my case that is Landscape Left).

I Closed this issue by removing Landscape Left orientation support. If any one have solution for this please share.

Thanks for help.

Était-ce utile?

La solution

I had the same problem, setting the 'Initial interface orientation' to UIInterfaceOrientationLandscapeLeft in the plist didn't work, nor did returning it in preferredInterfaceOrientationForPresentation in the view controller.

What solved this for me is reordering the 'Supported interface orientation' array in the plist to have my desired initial orientation as the first item in the array.

enter image description here

Autres conseils

Did you checked the orientation settings in your General settings of the project in XCode.

enter image description here

Replace your method shouldautotrotatetointerfaceorientation to

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top