问题描述
嘿,我有一个问题,就是我允许一个视图控制器以纵向和横向显示,但是当用户单击后退"按钮时,我想将应用的方向切换回纵向.目前,如果用户在横向模式下单击后退按钮,则应用程序的其余部分仍处于横向模式,是否有人遇到过自动旋转的解决方案?
Hey, I have an issue were I allow one viewcontroller to be displayed in portrait and landscape, however when the user hits the back button I want to switch the apps orientation back to portrait. At present if the user hits the back button when its in landscape mode the rest of the application stays in landscape mode, has anyone came across a solution for auto-rotating?
效果类似于使用[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
时发生的效果,但这是一个隐藏的API方法:-(
The effect is similar to what occurs when use [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
but this is a hidden API method :-(
推荐答案
我从您的问题中得到的是,您只想旋转一个视图的纵向和横向.如果那是您想要的,那么只需转到方法-(BOOL)应该AutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
What I got from your question is you want to rotate only one view portrait and landscape. If that is what you want, then just go to method- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
然后返回true,那么您唯一的那个视图就会旋转.
and then return true then your only that view will rotate.
这篇关于按下后退按钮时旋转到纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!