I started the Xcode template using GLKit but my intention is to have a window showing the OpenGL part of the view and UIKit for controls.
GLKViewController comes with a GLKView. I went to IB and removed the GLKView and added a UIView, putting a new GLKView on top at the size I want. Then I fixed the references to the GLKView (self.view) and set the smaller GLKView's delegate to the view controller.
I got
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[GLKViewController loadView] loaded the "2-view-9XZ-07-hga" nib but didn't get a GLKView.'
Then I looked at docs and find that GLKViewController requires GLKView as its view. No surprise. Yes I'm new at this.
What's a good way to use GLKit with a GLKView smaller than fullscreen? Or is mixing UIKit and GLKit just not done?
(update: a lot of people are finding this question; Duncan's answer, using view controller containment, worked well.)
You can, but GLKit doesn't make it obvious how.
The problem is that GLKViewController is designed so it's content view is a GLKView, as you say.
You have two choices.
Create a GLKView and put it in a regular view controller. That works fine.
Create a GLKViewController with a GLKView as its content, and make it a child view of another view controller, using the new parent/child view controller support in iOS 5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With