1

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?

ZeMoon
  • 20,054
  • 5
  • 57
  • 98

1 Answers1

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

Community
  • 1
  • 1
Volodymyr B.
  • 3,369
  • 2
  • 30
  • 48
  • Thanks a lot! You really saved my life... I had to call the viewController from within the SKScene, and this worked wonderfully! – ZeMoon Apr 11 '14 at 12:28
  • The problem with this approach is that I am being able to go from Portrait to landscape, but not the other way round. – ZeMoon Jul 04 '14 at 13:02