iphone - 结合 GLKView 与 UIBUtton

标签 iphone ios glkit

我正在寻找一个示例应用程序,它在同一窗口中使用 Apple 的新 GLKView 对象和其他 UIObject,例如 UIButton。我是从互联网上搜索的,我发现更像的帖子是 that并且没有回答:

在我正在创建的应用程序中,我需要在同一 View 中使用带有 2 个 UIButton 的 GLKView。根据我按下的按钮,我更改了 GLKView 的参数。 ViewController 应该如何处理 GLKView?我应该有一个与实际 View Controller 分开的 GLKViewController 来仅控制 GLKView 吗?

我试图让我的 View Controller 继承 GLKViewController。

@interface ViewController : GLKViewController <GLKViewControllerDelegate, GLKViewDelegate>

并在 viewDidLoadFunction 中设置名为 OpenGLView 的 GLKView:

- (void)viewDidLoad
{
[super viewDidLoad];

EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

openGlView.delegate = self;
openGlView.context = aContext;

openGlView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
openGlView.drawableDepthFormat = GLKViewDrawableDepthFormat16;
openGlView.drawableMultisample = GLKViewDrawableMultisample4X;

self.delegate = self;
self.preferredFramesPerSecond = 30;

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}

构建进行得很顺利,但是当我运行应用程序时它崩溃了:

'NSInternalInconsistencyException', reason: '-[GLKViewController loadView] loaded the "2-view-5" nib but didn't get a GLKView.'

有人可以帮助我吗?我正在为此搜索示例,但没有找到

乔迪·P

最佳答案

您收到的错误消息意味着 GLKViewController 子类,即您的 viewController,无法找到 GLKView 的预期导出。在 IB 中,您的 viewController 的 View 属性必须连接到 GLKView(或子类)才能正常工作。

关于iphone - 结合 GLKView 与 UIBUtton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8290662/

相关文章:

ios - 调整 GLKView 的大小

c# - MonoTouch 的性能问题?

iphone - kAudioSessionProperty_OtherAudioIsPlaying 始终返回 True

iphone - 在 UIImagePicker 中压缩视频时模拟器挂起

ios - 如何快速填充图案图像的颜色?

ios - 无法绘制不同数量的点

iphone - 如何将代码中的 IBOutlet 连接到界面生成器中的两个不同对象

ios - 是否可以在iOS中基于RGB值获得颜色名称?

ios - 在无效的 indexPath 处捕获了对 rect 的 NSInternalInconsistencyException 请求

ios - 使用 glReadPixels 读取 Tap Point 的值? OpenGL 2.0 iOS