1
votes

Ok so I've been reading tutorials and surfing through StackOverflow and I haven't been able to get an answer to this question.

I recently started developing iOS apps (this is my first one). I have a Tab Bar Controller and from there 5 different ViewControllers. As a default, it comes with FirstViewController and SecondViewController that I am able to modify their views in the StoryBoard and that I have them working "fine" for now. Now my question is how do I connect the other 3 missing ViewControllers to their respective .h and .m files? I tried creating a new Objective-C class with XIB user interface but I was not able to connect that XIB file to the main Tab Bar controller in the MainStoryboard.storyboard so I think I am missing something.

Any help would be greatly appreciated!

3

3 Answers

8
votes

Don't mix XIBs and storyboards. All you have to do is to create classes (declared in h and m files) that inherit from UIViewController without XIB files and specify the class name in the storyboard's object inspector. The "link" to the files is by referencing the class name in the inspector.

enter image description here

2
votes

Answer by Stavash is actually correct but u need to do something more.

You have to link the view property to the referencing outlet of the corresponding file.

After linking the class name to the xib do the following.

In xib file select the view controller -> in connections inspector -> drag and connect the view property to the view in xib.

I hope this will help.

1
votes

Basically add a new ViewController from the object Library, set its custom class to your view controller's class (ThirdViewController), and finally drag a relation segue from your tab bar controller to this new view controller, which will embed it into the tab bar.