Opening a view in Landscape mode [duplicate]

本小妞迷上赌 提交于 2019-12-23 20:22:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!