Force change interface orientation between scenes

旧巷老猫 提交于 2019-12-08 07:46:43

问题


How can I force the game to switch from portrait (Scene 1) to landscape mode (HomeScene) in between scenes?

I have two scenes, Scene1 (which is portrait) and HomeScene (which is designed to be landscape)

I am calling this line from Scene 1.

-(void)gotoHome
{
    //Would like to change interface orientation here.

    HomeScene *scene = [HomeScene sceneWithSize:self.size];
    [self.view presentScene:scene];
}

Problem is, both the scenes are being rendered on the same view. How can I tell a viewController to rotate itself?


回答1:


You can try use this trick, and this will call supportedInterfaceOrientations on your controller.

[self presentViewController:[UIViewController new] animated:NO completion:NULL];
[self dismissViewControllerAnimated:NO completion:NULL];

A bit more in this answer: https://stackoverflow.com/a/22982364/242882



来源:https://stackoverflow.com/questions/23011766/force-change-interface-orientation-between-scenes

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