在 iOS (iPad / iPhone) 上强制键盘和子视图方向
我们只是将用户输入放入我们的游戏中,以便用户可以输入电子邮件地址等。整个游戏是 GL 的,根本没有 iOS UI。 EAGLView 不会改变方向,它始终是纵向的,但游戏是横向的,我们通过相机变换来处理这个问题。
我们想要调出 iOS 键盘并覆盖一个 UITextView 用于文本输入。 UITextView 是 EAGLView 的子视图。显然,它和键盘以纵向方式显示,就像 EAGLView 一样。
无需将 EAGLView 更改为横向,有什么方法可以强制 UITextView 和键盘以横向显示?
如果我确实将 EAGLView 的方向更改为横向以使其正常工作,会对性能产生影响吗?我已经多次读到,在默认纵向视图之外的任何其他视图中定向 GL 视图都会对性能造成影响,尽管我找不到任何确凿的证据。
谢谢,
We are just putting user input into our game so the user can enter email address etc. The entire game is Gl with no iOS UI at all. The EAGLView does not change orientation, it is always in portrait, however the game is in landscape and we handle this with a camera transform.
We want to bring up the iOS keyboard and overlay a UITextView for the text input. The UITextView is a subview of the EAGLView. Obviously it, and the keyboard, shows up in portrait as the EAGLView is in portrait.
Without having to change the EAGLView to landscape is there any way I can force the UITextView and the keyboard to show up in landscape orientation?
If I do change the orientation of the EAGLView to landscape to get this working, is there any hit on performance? I have read several times that orienting a GL view in anything other than the default portrait view will give a performance hit, although I can't find any solid evidence of this.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们认为我们已经为此找到了解决方案。我们正在做两件事,一件事是针对键盘,另一件事是针对 UITextView。
对于键盘,我们正在设置状态栏方向。设置后键盘会跟随。
[UIApplication共享应用程序].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
为了让UITextView
正确定向,我们对 EAGLView 的子视图应用变换,在本例中只是 UITextView,如下所示。
这实际上为视图添加了 90 度旋转。
这已经在 iPad 和 iPad 上进行了测试。 iPhone 4 搭载 iOS 4.3,iPhone 3G 搭载 iOS 3.13。
We think we have come up with a solution for this. We are doing two things, one for the keyboard and the other for the UITextView.
For the keyboard we are setting the status bar orientation. The keyboard follows when set.
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
And to get the UITextView to orient correctly we apply a transform to subviews of our EAGLView, which in this case is only the UITextView, as follows.
This literally adds a 90 degree rotation to the view.
This has been tested on iPad & iPhone 4 with iOS 4.3, and on iPhone 3G with iOS 3.13.