开发者

UiViewController rotation question

开发者 https://www.devze.com 2023-02-01 12:37 出处:网络
I开发者_Python百科 have main menu in my app supporting only landscape mode. I implement landscape restriction by setting up UIRootViewController::shouldAutorotateToInterfaceOrientation:...

I开发者_Python百科 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.


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.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号