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:
- Create window.
- Create some auto-rotated UIViewControllers.
- Add their views to the window.
- Create an OpenGL ES view controller that’s not auto-rotated.
- Add its view to the window.
- Call bringSubviewToFront: for the auto-rotated views.
- Give yourself a high-five, while trying to ignore the nagging feeling that this is actually a nasty hack.
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.
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.