GLKView 与 UIBUtton 的结合
我正在寻找一个示例应用程序,该应用程序使用 Apple 的新 GLKView 对象以及同一窗口中的 UIButton 等其他 UIObject。我正在从互联网上搜索,我发现的更像是那个并且没有得到回答:
在我正在创建的应用程序中,我需要在同一视图中使用带有2个UIButton的GLKView。根据我按下的按钮,我会更改 GLKView 的参数。 ViewController 应该如何处理 GLKView?我应该有一个与实际视图控制器分开的 GLKViewController 来仅控制 GLKView 吗?
我试图让我的视图控制器继承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',原因:'-[GLKViewController loadView] 加载了“2-view-5”笔尖,但没有获得 GLKView。'
有人可以帮助我吗?我正在寻找一个例子,但我没有找到它
Jordi P
I'm looking for a sample application that uses Apple's new GLKView object whith other UIObjects like UIButton in the same window. I was searching that from the internet and the more like post I found wasthat and is not answered:
In the application I'm creating I need to use the GLKView with 2 UIButton in the same view. Depending of what Button I press I change the parameters of the GLKView. How the ViewController should handle the GLKView? Should I have a GLKViewController separate of the actual view controller to controll only the GLKView?
I tried to make my view controller inherit GLKViewController.
@interface ViewController : GLKViewController <GLKViewControllerDelegate, GLKViewDelegate>
And set up the GLKView named OpenGLView in the viewDidLoadFunction:
- (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);
}
The build goes well but when I run the application it crash saying:
'NSInternalInconsistencyException', reason: '-[GLKViewController loadView] loaded the "2-view-5" nib but didn't get a GLKView.'
Can someone help me? I was searching an example for this but I doesn't find it
Jordi P
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您收到的错误消息意味着 GLKViewController 子类(您的 viewController)无法找到 GLKView 的预期出口。在 IB 中,viewController 的 view 属性必须连接到 GLKView(或子类)才能正常工作。
The error message you're getting means that the GLKViewController subclass, your viewController, cannot find the expected outlet to a GLKView. In IB the view property of your viewController MUST be connected to a GLKView (or subclass) to work correctly.
转到 Storyboard,选择 GLKViewController 中的视图,并将其设置为 GLKView 类。
Go to the Storyboard, select the view inside the GLKViewController, and set it as GLKView class.