当我单击“后退"按钮时,我的视图从横向变为纵向 [英] When I click the back button my view changes from landscape to portrait

查看:65
本文介绍了当我单击“后退"按钮时,我的视图从横向变为纵向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用情节提要,将我的应用设置为左右水平.我有一个视图控制器,单击可转到下一个视图并执行任何操作,完成后,单击后退"按钮.发生的事情是,当我单击后退按钮时,水平视图切换为纵向视图,并弄乱了整个应用程序.我将自己的命令设置为推送,但我确实将其设置为模态.

I am using storyboard and have my app set to be only horizontal left and right. I have a view controller where I click to go to my next view and do whatever, and when I am done I click the back button. What happens is when I click the back button the horizontal view switches to portrait and messes my whole app up. I have my segues set as push, but I did have them at modal.

然后转到我的下一个屏幕

Then it goes to my next screen

当我单击返回时,由于某种原因,它会切换为纵向,如下所示:

When I click back, it for some reason switches to portrait and looks like this:

我不知道为什么要这么做……还有其他人有这个问题或对发生的事情有什么想法吗???

I have no idea why it would do this... Has anybody else had this problem or have an idea of whats going on???

推荐答案

您需要检查并将rootViewController的方向设置为仅横向.然后确保将所有其他viewControllers方向都设置为推断.

You need to go through and set your rootViewController's orientation to landscape only. Then make sure all other viewControllers orientations are set to inferred.

如果您还没有进入info.plist并确保仅支持横向,这也是一个好主意.

It is also a good idea if you haven't already to go into your info.plist and make sure you have supported only landscape orientations.

此外,您可能需要向viewControllers中添加一些类似于以下内容的代码:

Also you may need to add some code to your viewControllers that looks something like this:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

这篇关于当我单击“后退"按钮时,我的视图从横向变为纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆