Cocoa - 如何在故事板模式下将视图的代理连接到文件所有者? [英] Cocoa - How to connect view's delegate to file's owner in storyboard mode?

查看:154
本文介绍了Cocoa - 如何在故事板模式下将视图的代理连接到文件所有者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用.xib时,我通过界面生成器将视图的代理连接到文件的所有者,然后进入视图控制器的.h文件,并将其设置为代理以完成连接。



然而在storyboard模式下,没有文件的所有者对象。我使用一个称为NinevehGL的引擎,这简化了使用openGL渲染模型的过程。这个引擎需要我创建一个视图,将它的类设置为NGLView,将它的委托连接到文件的所有者对象,并添加到视图控制器.h文件的头文件中以完成连接(然后实现适当的方法,如在视图控制器中的drawView)。



我显然更喜欢在xcode中采用新的故事板技术,但我不能似乎找出了如何模仿我通常在一个.xib与故事板中的过程。苹果文档提到使用rootViewController,但解释是有点模糊。



任何人都可以向我解释这个过程吗?



现在使用storyboards,实现特定场景的视图控制器包含在场景本身中。您可以在场景下方的栏中查看它(参见图片)



因此,在您之前与文件所有者建立连接之前,现在您直接将它们发送到视图控制器。不要忘记将该视图控制器对象的类设置为正确的类。




When I use an .xib, I connect a view's delegate to the File's Owner via interface builder, then go into the view controller's .h file and set it as the delegate to complete the connection via .

However in storyboard mode, there is no file's owner object. I am using an engine called NinevehGL, which simplifies the process of rendering models with openGL. This engine requires that I create a view, set it's class to NGLView, connect it's delegate to the file's owner object, and add to the header file of the view controller .h file to complete the connection (and then implement the appropriate methods such as drawView in the view controller). This all work's great via .xib files, but how do I accomplish this via a storyboard?

I would obviously prefer to adopt the new storyboarding technique in xcode, but I cant seem to figure out how to mimic the process I normally do in an .xib with a storyboard. The apple docs mention the using the rootViewController, but the explanation is a little fuzzy.

Can anyone explain the process to me?

解决方案

In nibs earlier, typically the file's owner was just the view controller that loaded its view from that nib.

Now with storyboards, the view controller that implements a particular scene is included with the scene itself. You can see it in the bar below the scene (see pic)

So where you made connections to the file's owner before, now you make them directly to the view controller. Don't forget to set the class of that view controller object to the correct class.

这篇关于Cocoa - 如何在故事板模式下将视图的代理连接到文件所有者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆