强制更改场景之间的界面方向 [英] Force change interface orientation between scenes
问题描述
如何强制游戏在场景之间从纵向(场景1)切换到横向模式(HomeScene)?
How can I force the game to switch from portrait (Scene 1) to landscape mode (HomeScene) in between scenes?
我有两个场景,Scene1(肖像)和HomeScene(设计为风景)
I have two scenes, Scene1 (which is portrait) and HomeScene (which is designed to be landscape)
我在场景1中调用此行。
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];
}
问题是,两个场景都在同一个视图上呈现。如何告诉viewController自行旋转?
Problem is, both the scenes are being rendered on the same view. How can I tell a viewController to rotate itself?
推荐答案
你可以尝试使用这个技巧,这将调用您的控制器上的supportedInterfaceOrientations
。
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];
在这个答案中多一点:$ b $ b https://stackoverflow.com/a/22982364/242882
A bit more in this answer: https://stackoverflow.com/a/22982364/242882
这篇关于强制更改场景之间的界面方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!