简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM