如何在按下按钮时加载另一个 xib
我有一个项目,其中有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从视图控制器发送 [[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.