设置RootViewController时的方向问题 [英] Orientation problem when I set a RootViewController

查看:60
本文介绍了设置RootViewController时的方向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个通用的ios游戏而且我有一个方向问题。我的应用程序都处于横向模式。如果我做presentModelViewController都没问题,但如果我做setRootViewController,新的控制器会以纵向模式出现。



我做错了什么?

解决方案

我不确定如果这是你的问题,但我有一个应用程序,从纵向模式下的一个视图控制器开始,然后我试图在横向模式下呈现第二个视图控制器。我也使用setRootViewController技术,因此我不必解除分配/重新分配第二个视图控制器并丢失我的状态信息,因为用户将经常在两个视图之间切换。



我遇到了同样的问题,即第二个视图控制器总是以纵向模式而不是横向显示,即使视图控制器本身指定它从不允许纵向模式。



对我来说,修复是为了确保在应用程序委托中我使用



$ b <$ p来呈现第一个视图控制器$ p> [window setRootViewController:controller];

而不是

  [window addSubview:controller.view]; 

这是一个较旧的应用程序,原始模板默认使用addSubview。似乎如果没有指定原始根视图控制器,则必要的方向消息将永远不会进入设置为root的后续视图控制器。希望有所帮助!


I'm doing an universal ios game and I'm having an orientation problem. My app is all in landscape mode. If I do presentModelViewController is all ok, but if I do setRootViewController, the new controller appear in portrait mode.

What am I doing wrong?

解决方案

I'm unsure if this was your problem, but I have an application that starts with one view controller in portrait mode and then I'm trying to present a second view controller in landscape mode. I'm using the setRootViewController technique as well so that I do not have to deallocate/reallocate the second view controller and lose my state information since users will be switching between the two views frequently.

I had the same issue where the second view controller would always be displayed in portrait mode instead of landscape, even though the view controller itself specifies that it never allows portrait mode.

The fix for me was to make sure that in the application delegate I presented the first view controller using

[window setRootViewController:controller];

instead of

[window addSubview:controller.view];

This was an older application, and the original template used addSubview by default. it seems that if there was not an original root view controller specified, the necessary orientation messages will never make it to subsequent view controllers that are set as root. Hope that helps!

这篇关于设置RootViewController时的方向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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