Cocoa - How to connect view's delegate to file's owner in storyboard mode?

自作多情 提交于 2019-12-21 07:19:16

问题


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?


回答1:


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.




回答2:


your NGLView should be in a view controller - you could use that view controller as the delegate.



来源:https://stackoverflow.com/questions/8636542/cocoa-how-to-connect-views-delegate-to-files-owner-in-storyboard-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!