Xcode - How to connect XIB to ViewController Class

mogio picture mogio · Jun 27, 2012 · Viewed 86.4k times · Source

I created first my TestViewController.h and *.m. Afterwards my TestView.xib.

Now I need to tell my xib: "Yes, please take the class TestViewController as my File's Owner".

I open up my xib, go to the Identity Inspector of its fileOwner and choose under "Custom Class" TestViewController.

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 !

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?

Answer

Augustine picture Augustine · Jun 27, 2012

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.

enter image description here