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

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

问题描述

我正在做一个应用程序,其中有一个我不想自动旋转的 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. 将他们的视图添加到窗口中.
  4. 创建一个 自动旋转的 OpenGL ES 视图控制器.
  5. 将其视图添加到窗口中.
  6. 调用 bringSubviewToFront: 以获得自动旋转的视图.
  7. 给自己一个高五,同时尽量忽略这实际上是一个令人讨厌的黑客的唠叨感觉.
  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.

有人知道更好的解决方案吗?注意:我非常肯定我想自动旋转 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. =)

推荐答案

没有比你建议的更好的方法了.

There isn't a good way to do this any better than what you proposed.

您确定不只是想旋转 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.

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

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