Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode - How to connect XIB to ViewController Class

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?

like image 549
mogio Avatar asked Jun 27 '12 11:06

mogio


People also ask

How do I load a XIB file in Swift?

Remember to name your Xib file exactly as your UIView subclass and set the type of the main view in that Xib file correctly. As soon as SE-0068 will be implemented one could drop the protocol and move the function directly into the UIView extension.


1 Answers

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

like image 50
Augustine Avatar answered Sep 17 '22 18:09

Augustine