Xcode - 如何将 XIB 连接到 ViewController 类 [英] Xcode - How to connect XIB to ViewController Class
问题描述
我首先创建了我的 TestViewController.h 和 *.m.之后我的 TestView.xib.
I created first my TestViewController.h and *.m. Afterwards my TestView.xib.
现在我需要告诉我的 xib:是的,请将 TestViewController 类作为我的文件所有者".
Now I need to tell my xib: "Yes, please take the class TestViewController as my File's Owner".
我打开我的 xib,转到其文件所有者的身份检查器,然后在自定义类"TestViewController 下选择.
I open up my xib, go to the Identity Inspector of its fileOwner and choose under "Custom Class" TestViewController.
但这似乎还不够——因为当我打开 TestView.xib,然后选择Assistent Editor View"时,它应该在分屏的右侧显示相应的 ViewController——在我的例子中是TestViewController.H".但它没有!
But this seems not enough - as when I open up the TestView.xib, and then choose the "Assistent Editor View" it should bring up the corresponding ViewController on the right part of the split screen - in my case the "TestViewController.h". But it doesn't !
是否有必要通过将线条拖到文件中来以任何方式将 xib 绑定到其视图控制器,就像您使用插座和动作所做的那样?
Is it necessary to bind the xib in any way to its viewcontroller by dragging lines to files like you do it with outlets and actions?
推荐答案
单击以选择 xib.现在,选择文件的所有者.在右侧的属性面板中,选择第三个选项卡身份检查器".有一个名为自定义类的标题.在那里给你的视图控制器的名字.在此之后,您可以将元素与文件的所有者联系起来.
Click to select the xib. Now, select the file's owner. In the attribute panel on the right side, choose the third tab, "Identity Inspector". There is a header named Custom Class. Give your view controller's name there. After this, you can connect the elements with the file's owner.
这篇关于Xcode - 如何将 XIB 连接到 ViewController 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!