多个 XIB/NIB 文件:IBOutlets 未连接

发布于 2024-09-28 20:01:51 字数 681 浏览 1 评论 0原文

我有两个 UIViewController 子类,A 和 B。

在 A.xib 中,我嵌入了一个“B”UIViewController,将其 NIB 名称设置为“B”,并将其委托和 IBActions 附加到文件所有者,即 A。

在 B 中.xib 我已经定义了一个视图,并将其各种 IBOutlet 附加到文件所有者,即 B。

在图形中,您可以看到两个 XIB,A 在左侧,B 在右侧。在每个 XIB 中,都会出现一个类型为“B”UIViewController 的实体(在右侧文件中,它是文件的所有者)。在左侧 XIB(例如委托)中连接一些引用和出口,在右侧连接一些引用和出口(例如视图组件)是有意义的。

在此处输入图像描述

令人不满意的结果是,在 viewDidLoad: 中,只有左侧文件中定义的 Outlets/actions/references ( A.xib) 已连接。

这样做的正确方法是什么?我可以让它在代码中工作 - 显式创建“B” UIViewController,插入其视图,连接其委托 - 但我正在尝试使用 Interface Builder 寻求“正确”的方法。

尽管 stackoverflow 上的其他问题涉及多个 xib/nib IBOutlet 连接问题,但不知怎的,它们似乎都没有解决这种情况。

I have two UIViewController subclasses, A and B.

In A.xib I have embedded a "B" UIViewController, set its NIB Name as "B", and attached its delegate and IBActions to the File's Owner, which is an A.

In B.xib I have defined a view and attached its various IBOutlets to the File's Owner, which is a B.

In the graphic you can see the two XIBs, A on the left and B on the right. In each XIB there appears an entity whose Type is a "B" UIViewController (in the right file it's the File's Owner). It makes sense to hook up some references and outlets in the left XIB (eg. delegate), and some on the right (eg. view components).

enter image description here

The unhappy result is that in viewDidLoad:, only the outlets/actions/references defined in the left file (A.xib) are connected.

What is the correct way of doing this? I can make it work in code — explicitly creating the "B" UIViewController, inserting its view, hooking up its delegate — but I am trying for the "right" approach using Interface Builder.

Although other questions on stackoverflow refer to multiple xib/nib IBOutlet connection problems, somehow none of them seem to address this situation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文