Pregunta

My app should start with landscape mode. I would like to change the orientation of the phone. How to do this manually.I tried this it doesn't work.

 shouldAutorotateToInterfaceOrientation:

Is there any other way??

¿Fue útil?

Solución

In the project settings, you can set the orientations your app permits. Set it to LandscapeLeft and LandscapeRight. That will prevent your app from going into Potrait mode, irrespective of the orientation of device before your app was started.

MANUALLY FORCE CHANGE ORIENTATION

In iOS, you cannot directly set the device orientation manually. However, you can use this method to get your work done.

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft  animated:NO];

THE USUAL WAY

Alternatively, you can goto your implementation file where you can specify the allowed orientations in this method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//Return YES if you want to allow all orientations
return UIInterfaceOrientationLandscapeRight; //if you want to allow landscape right &c
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top