如何在按下按钮时加载另一个 xib

发布于 2024-09-28 03:53:45 字数 154 浏览 0 评论 0原文

我有一个项目,其中有一个 ViewController 和两个 xib 文件。我在视图控制器中显示的视图上有两个按钮。两个按钮都处于活动状态并返回 NSLog,因此我知道它们正在工作。基本上我想在按下按钮时加载 xib。我在每个 xib 中都有一个视图设置。

提前感谢您的帮助!

I have a project where where i have one ViewController and two xib files. I have two buttons on a view which is shown in the viewcontroller. Both buttons are active and returning a NSLog so i know they are working. Basically I would like to load a xib when the button is pressed. I have a view setup in each xib.

Thanks for your help in advance!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

述情 2024-10-05 03:53:45

从视图控制器发送 [[NSBundle mainBundle] loadNibNamed: @"MyXib" Owner: self options: nil] 。当 xib 加载时,视图控制器将按照 xib 中指定的方式连接其 Interface Builder 出口。确保在 IB 中您已将文件所有者的类设置为视图控制器的类并连接了您需要的插座。

Send [[NSBundle mainBundle] loadNibNamed: @"MyXib" owner: self options: nil] from your view controller. When the xib gets loaded the view controller will connect its Interface Builder outlets as specified in the xib. Make sure that in IB you've set the class of File Owner to your view controller's class and connected the outlets you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文