菜鸟教程小白 发表于 2022-12-11 20:36:03

iphone - 将 GLKView 与 UIBUtton 相结合


                                            <p><p>我正在寻找一个示例应用程序,它在同一窗口中使用 Apple 的新 GLKView 对象以及 UIButton 等其他 UIObjects。我从互联网上搜索,发现更像是 <a href="http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&amp;Number=305876#Post305876" rel="noreferrer noopener nofollow">that</a> 的帖子并且没有回答:</p>

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

<p>我试图让我的 ViewController 继承 GLKViewController。</p>

<pre><code>@interface ViewController : GLKViewController &lt;GLKViewControllerDelegate, GLKViewDelegate&gt;
</code></pre>

<p>并在viewDidLoadFunction中设置名为OpenGLView的GLKView:</p>

<pre><code>- (void)viewDidLoad
{
;

EAGLContext *aContext = [ 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);
}
</code></pre>

<p>构建顺利,但是当我运行应用程序时它崩溃说:</p>

<blockquote>
<p>&#39;NSInternalInconsistencyException&#39;, reason: &#39;- loaded the &#34;2-view-5&#34; nib but didn&#39;t get a GLKView.&#39;</p>
</blockquote>

<p>有人可以帮助我吗?我正在为此搜索一个示例,但我没有找到它</p>

<p>乔迪·P</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您收到的错误消息意味着 GLKViewController 子类(您的 viewController)无法找到 GLKView 的预期导出。在 IB 中,viewController 的 view 属性必须连接到 GLKView(或子类)才能正常工作。</p></p>
                                   
                                                <p style="font-size: 20px;">关于iphone - 将 GLKView 与 UIBUtton 相结合,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/8290662/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/8290662/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iphone - 将 GLKView 与 UIBUtton 相结合