Does storyboard eliminate the need for .nib

William Sham picture William Sham · Dec 13, 2011 · Viewed 8.5k times · Source

With the introduction of storyboard, I wouldn't select to create a .xib/.nib when I create a subclass of UIViewController, because I can just drag out a viewcontroller in interface builder and assign it to the new class.

So, with storyboard, when would i need to use the .xib/.nib file?

Thank you.

Answer

Tim picture Tim · Dec 13, 2011

Storyboards don't completely remove the need for NIB files. One common example is when creating subviews to go inside a UIScrollView. You can't create the subviews separately in a storyboard; instead you have to create separate NIB(s) for the subviews and attach them to the scroll view programatically.

In fact, on almost any occasion where you have a need for subviews which change at runtime you'll want to use separate NIBs.

Storyboards are great for certain kinds of apps, but for anything even remotely complicated the old way works very well still. An additional benefit is that they co-exist nicely. You can put placeholder views in your storyboard and fill them programatically with NIB-defined views later on.