OGeek|极客世界-中国程序员成长平台

标题: iphone - 将 GLKView 与 UIBUtton 相结合 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:36
标题: iphone - 将 GLKView 与 UIBUtton 相结合

我正在寻找一个示例应用程序,它在同一窗口中使用 Apple 的新 GLKView 对象以及 UIButton 等其他 UIObjects。我从互联网上搜索,发现更像是 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



Best Answer-推荐答案


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

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






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4