Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading a UIViewController xib to ContainerView in storyboard

I have a "container" viewController, that hold a few container views using storyboard. each of that container view has a link to an embedded viewcontroller's view.

Since im working on a big project, it turns out that the storyboard file is massive and contains a lot of "child" viecontrollers view layout. it will be a problem working on that file when a few people needs to be working simultaneously on it. and thats not good for me. i would like to know if theres a way to load into each container view a viewcontroller's xib file, and still be using storyboard.

Meaning, creating .xib files for each viewcontroller instead of holding them in the storyboard itself, and link them to the container views in the storyboard.

thanks,

like image 912
Lirik Avatar asked Dec 27 '12 12:12

Lirik


People also ask

Which is better XIB or storyboard?

It is not to tell which one is the best. because which one is good to tell based on team requirement. If you are a single developer, it is good to use storyboard because it consumes less time. If the team consists of many developers, use xib, otherwise, it is not easy to merge the modules/tasks.


1 Answers

You can move your view controller layout into a separate xib. As you say, this is a very convenient way to share layouts across storyboards.

When setting up a container view in your storyboard, make sure you delete the provided view in the embedded ViewController. Set the custom class for the ViewController to your class name. Name the xib to match the class (e.g. FooViewController.xib so it can be found when FooViewController.m is loaded.)

If you don't delete the View in the storyboard view controller layout, you'll see that empty view instead. Your viewDidLoad method in your view controller won't be called, because the View is the default Storyboard View.

I'm using Xcode 6.1 for iOS 8 on a pre-iOS 7 project.

like image 150
Nuthatch Avatar answered Nov 15 '22 12:11

Nuthatch