Question

I have main menu in my app supporting only landscape mode. I implement landscape restriction by setting up UIRootViewController::shouldAutorotateToInterfaceOrientation:... And I have another scene with portrait mode support. So the problem appears when I pass from another scene to main menu in portrait mode: the app doesn't rotate to landscape automatically, and I can't find a code method to manually rotate it.

Is there a solution? Would be thankful.

Edit: Excuse me, I forgot to add details. RootViewController is common for menu and another scene. And what is more - these scenes are in one common view (my app uses OpenGL) So before I enter menu from portrait scene I set UIRootViewController::shouldAutorotateToInterfaceOrientation: to return YES for landscape only.

Was it helpful?

Solution

If your other scene with portrait support is controlled by another UIViewController, then you can use that view controller's -shouldAutorotateToInterfaceOrientation: to define its behavior. In many cases, this alone should be enough. Of course, if you need to do some fancy rotations for some view controller but not for others, then things get a bit trickier.

OTHER TIPS

There is no easy way to do this, except [UIDevice setOrientation:], which is not open to developers, and leads to application rejection by Apple.

You can apply a rotation to your layer which will create the exact same effect.

myview.layer.transform = CATransform3DMakeRotation(M_PI/2, 0.0f, 0.0f, 1.0f);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top