旋转一些UIViews,但不是全部? [英] Rotate some UIViews, but not all?

查看:164
本文介绍了旋转一些UIViews,但不是全部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个应用程序,其中我有一个GLES视图,我不想被自动旋转,而UIKit视图顶部,这是需要自动旋转。

I'm doing an app where I have a GLES view which I don't want to be auto-rotated, and UIKit views on top of that, which do need to be auto-rotated.

显然这不是你应该做的,因为我找不到任何好的文档。

Apparently this is not something you're supposed to be doing, as I can't find any good documentation on it. However I'm totally sure this is exactly what I want.

我找到了一个解决方案,但感觉很怪:

I've found a solution, but it feels hacky:


  1. 创建窗口。

  2. 创建一些自动旋转的UIViewControllers。


  3. 创建不自动旋转的OpenGL ES视图控制器。

  4. 将其视图添加到窗口。
  5. 调用bringSubviewToFront:用于自动旋转的视图。

  6. 给自己一个高五,同时试图忽略笨拙的感觉,讨厌的黑客。

  1. Create window.
  2. Create some auto-rotated UIViewControllers.
  3. Add their views to the window.
  4. Create an OpenGL ES view controller that's not auto-rotated.
  5. Add its view to the window.
  6. Call bringSubviewToFront: for the auto-rotated views.
  7. Give yourself a high-five, while trying to ignore the nagging feeling that this is actually a nasty hack.

任何人都知道更好的解决方案? NB:我绝对肯定,我想自动旋转UIKit视图而不是GL视图。

Anyone know of a better solution? NB: I'm absolutely positive that I want to auto-rotate the UIKit views and not the GL view.

感谢您的时间,非常感谢。 =)

Thanks for your time, much appreciated. =)

推荐答案

没有比这更好的方法。

你确定你不只是想旋转OpenGL视图吗?如果您的应用程序仅限于ES 2.0设备,稍后在iOS 4.2上,则对于OpenGL视图使用UIViewController旋转不会​​再有任何性能损失。

Are you sure you don't just want to rotate the OpenGL views too? If your application is limited to the ES 2.0 devices and later on iOS 4.2, there is no longer any performance penalty to using UIViewController rotation for OpenGL views.

这篇关于旋转一些UIViews,但不是全部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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