XIB实例化的对象的IBOutlet是nil [英] XIB-instantiated Object's IBOutlet is nil

查看:483
本文介绍了XIB实例化的对象的IBOutlet是nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XIB设置,如下面的截图:





文件的所有者是我的主窗口控制器。 XIB还负责创建用作 MGScopeBar 视图的代理的对象。从截图中可以看到,范围条委托对于搜索字段有一个 IBOutlet ,以便它可以作为委托过程的一部分作为一个额外的视图返回。 / p>

我遇到的问题是,当委托对象被查询附件视图时, IBOutlet NSSearchField 为nil。我相当确定这有关的对象创建的顺序,IBOutlets有线等,但我只是有点失去,在过程中我可以期望搜索字段存在,以便范围栏

解决方案



<

Apple的文档,看起来像NIB / XIB中的所有插座应该在 awakeFromNib 调用之前连接在对象上调用 init 等时,该NIB / XIB中的任何对象,但是outlet 可能 >

I have a XIB set up like in this screenshot:

File's owner is my main window controller. The XIB is also in charge of creating an object that serves as the delegate for the MGScopeBar view. As you can see in the screenshot, the scope bar delegate has an IBOutlet for the search field so that it can return it as an extra view as part of the delegate process.

The problem I'm having is that when the delegate object is queried for the accessory view, the IBOutlet NSSearchField is nil. I'm fairly certain this has something to do with the order that objects are created, IBOutlets wired, etc, but I'm just a little lost as to where in the process I can expect the search field to exist so that the scope bar delegate can reference it properly.

Thanks in advance for any pointers.

解决方案

Per Apple's documentation, it looks like all of the outlets in a NIB/XIB are supposed to be wired before awakeFromNib is called on any object in that NIB/XIB, but that outlets probably are not wired when init, etc., are called on the objects.

这篇关于XIB实例化的对象的IBOutlet是nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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