【问题标题】:When I click the back button my view changes from landscape to portrait当我单击后退按钮时,我的视图从横向变为纵向
【发布时间】:2012-08-01 16:25:29
【问题描述】:
我正在使用情节提要,并将我的应用设置为仅水平左右。我有一个视图控制器,我单击以转到下一个视图并执行任何操作,完成后单击后退按钮。发生的情况是,当我单击后退按钮时,水平视图会切换为纵向视图,并将我的整个应用程序弄乱了。我将我的 segues 设置为 push,但我确实将它们设置为模态。
然后它进入我的下一个屏幕
当我点击返回时,它出于某种原因切换到纵向,看起来像这样:
我不知道它为什么会这样做...有其他人遇到过这个问题或知道发生了什么吗???
【问题讨论】:
标签:
ios
xcode
ipad
storyboard
uistoryboardsegue
【解决方案1】:
您需要将 rootViewController 的方向设置为仅横向。然后确保所有其他 viewControllers 方向都设置为 inferred。
如果您还没有进入 info.plist 并确保您只支持横向方向,这也是一个好主意。
此外,您可能需要向 viewControllers 添加一些代码,如下所示:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}