How to convert a NIB-based project to a Storyboard-based?

15,059

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.

Share:
15,059

Related videos on Youtube

Xander
Author by

Xander

\m/

Updated on June 04, 2022

Comments

  • Xander
    Xander almost 2 years

    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?

  • DawnSong
    DawnSong over 3 years
    One more thing, just copy the view in xib and paste to replace the view controller's view in your storyboard, then all copied subviews and constraints will be same with the xib. However, IBOutlet and IBAction won't be copied automatically, so you have to connect them manually.