The Story of no Storyboard in iOS Development

The Story of no Storyboard in iOS Development

When I create a new iOS project in Xcode, being iPhone/iPad only or universal, the first thing I do after creating the project is delete the Storyboard.

And no, I don't delete the Storyboard because I want to use XIBs instead - I keep away from Interface Builder completely.

There was a great discussion about this in the Treehouse forum and the story I keep hearing is the same: Interface Builder encourages bad practices.

Since I have a long background developing on the Windows platform using Visual Studio, I'm confident to say that Interface Builder is outright bad, at least in comparison. What makes Visual Studio even more superior, is the markup language (XAML) that sits underneath the designer which feels exactly the same to edit as HTML does for the web.

Anyway, back to iOS.

The worst part about using Interface Builder is that it makes it more work to split chunks of a view into their own and use from the view controller. The result of this is those huge view controllers that you should avoid, and it becomes a nightmare to edit.

Even if you do the extra work and extract chunks of your UI into reusable views, all you'll see inside Interface Builder is white boxes that are the containers of the reusable views, but you don't get to see the actual view.

Another thing is outlets. They accidentially get orphaned during merge, or you forget to connect them when reusing a view, and your app will crash.

Some might argues that given new screen sizes, using IB with Auto Layout is the way to go. But I still disagree - first of all I think it's a nightmare to manage layout constraints in IB. It's hard to drag and drop around views and achieve precise contraints. Elements snap to adjacent views all the time, and when you touch a couple of boxes they escalade and change others.

Instead, there's quite a few Auto Layout helper repos on GitHub to make your life easier, after instatiating your subviews inside your view controller, you override updateConstraints and setup constraints, like the following example using the PureLayout library:

As for table views and calculating the height of each cell, it is quite straight forward to achieve auto sized cells using auto layout constraints, especially since iOS 8 where the UITableViewAutomaticDimension option was introduced.