问题
I am developing an application in portrait mode.In my one view controller when I click on table view another view opened in portrait mode.I want it to be opened in landscape mode. Please suggest me how to do this. Thanks in advance!!
回答1:
As far as I know, the only way to achieve this is to to show the view controller as a modal with
[self presentModalViewController:landscapeViewController animated:YES];
and specify the landscape mode in
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationLandscapeLeft == interfaceOrientation;
}
This is because if a modal view can appear in only one orientation, the app automatically rotates to that orientation.
See the accepted answer for this question for more details: Transitioning to landscape rotation within a uinavigationcontroller
回答2:
I think that'l do:
[[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight];
Im not sure though...
回答3:
I'm pretty sure you cannot use setOrientation
anymore, since it is deprecated and apps have been declined for using it.
This may be an option for you:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/33548-alternative-setorientation.html
It rotates the view using a transformation.
来源:https://stackoverflow.com/questions/5755690/opening-a-view-in-landscape-mode