2

I have been trying to figure this out without success. I created a storyboard which has a GLKView embedded in a GLK View Controller (I can't post an image since I don't have enough reputation points yet). I can't seem to have my drawing code use the GLKView rather than the GLK View Controller's view for drawing. I've tried doing the following in ViewDidLoad in myGLKViewController.m:

GLKView *view = (GLKView *)self.view;
view.context = self.context;

// adding to make myGLKView the actual view used
self.view.frame = _myGLKView.frame;
[self.view addSubview:_myGLKView];

[Note: _myGLKView is the outlet for the embedded GLKView in the storyboard. Using the debugger, it does have the correct bounds, so I know I'm on the right track]. I've tried various combinations of this and I can't get it to work at all. I'm using the xcode 4.5.1 and iOS 6. Thanks in advance for any ideas.

MarkV309
  • 51
  • 5

1 Answers1

0

When you load from the storyboard, the view that's loaded with the controller is the embedded view, so it appears you are trying to add your view as a subview of itself. The likely result is that your view is no longer connected to the window, and won't display.

If you remove the call to addSubview and your custom outlet, you should just be able to use self.view, which is already represents the connection through an outlet in your view controller's superclass.

Steven McGrath
  • 1,717
  • 11
  • 20