Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a NIB-based project to a Storyboard-based? [closed]

I'm using storyboard (this is completely new!).

How do I import my existing xib files and integrate them onto a single file, using the storyboard option?

like image 831
Xander Avatar asked Nov 21 '11 07:11

Xander


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.

What is NIB file in iOS?

A nib file is a special type of resource file that you use to store the user interfaces of iOS and Mac apps. A nib file is an Interface Builder document.

What is a storyboard file?

A STORYBOARD file is a user interface (UI) storyboard created by Apple Xcode's Interface Builder. It contains one or more screen layouts, which are connected to show an app's event and UI flow. Developers create STORYBOARD files while developing iOS applications.


1 Answers

There is not a 1-click way to do this. According to "Sams Teach Yourself Core Data for Mac and iOS in 24 Hours" by Jesse Feiler, storyboards are different enough in their developer interfaces that it makes sense not to convert existing nib but to use them for new projects. One of the larger differences the way view transitions are handled. However, I did take the plunge and feel it was worth it because I was still near the beginning of a larger project. Doing so will entail a manual process. Apple Converting to Storyboards Release Notes addresses how to add storyboard to the project. This will get you a storyboard but your existing xibs will not be imported into the storyboard. I didn't do this. I started with a fresh project and copied over the custom view controller classes I wanted to re-use (.h and .m). Then I proceeded to build my storyboard and cut and pasted from the old projects xib files using interface builder when it made sense. It really doesn't take that long. After you assign your custom view controllers to the control your views in storyboard you will want to take out the IBActions out of your code that select view transitions and replace them with storyboard segues. The segues are added in storyboard and you have the option of adding a prepareForSegue method in your view controller. The optional prepareForSegue method is used finishing up anything in the source view controller and setting up the destination view controller before the transition.

like image 149
T.J. Avatar answered Oct 08 '22 04:10

T.J.