Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use iOS GLKit without using a full screen view?

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.)

like image 961
Adam Eberbach Avatar asked Apr 19 '12 20:04

Adam Eberbach


1 Answers

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.

  1. Create a GLKView and put it in a regular view controller. That works fine.

  2. 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.

like image 119
Duncan C Avatar answered Oct 11 '22 20:10

Duncan C