Can I use iOS GLKit without using full screen?

I started using the Xcode template with GLKit, but I would like to have a window showing part of the OpenGL view and UIKit for the controls.

GLKViewController comes with GLKView. I went to IB and removed GLKView and added UIView, putting the new GLKView on top of the size I want. Then I fixed the GLKView links (self.view) and set the smaller GLKView 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 through the docs and found that GLKViewController requires GLKView as its view. Not surprising. Yes, I'm new to this.

What a good way to use GLKit with GLKView smaller than full screen? Or is the mix of UIKit and GLKit simply not done?

(update: many people find this question, Duncan's answer, using view controller containment, worked well.)

+7
source share
1 answer

You can, but GLKit does not make it obvious how to do this.

The problem is that the GLKViewController is designed so that the content view is a GLKView, as you say.

You have two options.

  • Create a GLKView and put it in a regular controller. It works great.

  • Create a GLKViewController with GLKView as its contents and make it a child view of another view controller using the new parent / child view controller support in iOS 5.

+8
source

All Articles