Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the benefits of using Storyboards instead of xib files in iOS programming?

What are the main differences between using Storyboards and xib files.

Specifically, what are the advantages or disadvantages of using a Storyboard?

Unfortunately, despite doing quite a bit of research, all I've been able to find on Storyboards are simple tutorials that show you how to set up a Storyboard, instead of concrete information explaining what they are.

like image 459
Steve Avatar asked Jan 31 '12 17:01

Steve


People also ask

What is better XIB or storyboard?

Storyboards - this is a visual tool for laying out multiple application views and the transitions between them (segues). XIBs (or NIBs) - each XIB file corresponds to a single view element and can be laid out in the Interface Builder, making it a visual tool as well.

Why are storyboards great features in iOS development?

Storyboards are an exciting feature first introduced in iOS 5, which save time building user interfaces for your apps. Storyboards allow you to prototype and design multiple view controller views within one file, and also let you create transitions between view controllers.

Is storyboard better than SwiftUI?

Storyboard Advantages over SwiftUIIt is easier to use Storyboard as a beginner . Storyboard consist of Xib and custom View which can be reusable in the projects. It is easier to build an app as there is only drag and drop of the elements of the storyboard.

What is difference between XIB and NIB?

In fact, the acronym "NIB" comes from "NeXTSTEP Interface Builder", and "XIB" from "Xcode Interface Builder". NIBs and XIBs are effectively the same thing: XIBs are newer and are used while you're developing, whereas NIBs are what get produced when you create a build.


2 Answers

A Storyboard is:

  • A container for all your Scenes (View Controllers, Nav Controllers, TabBar Controllers, etc)
  • A manager of connections and transitions between these scenes (these are called Segues)
  • A nice way to manage how different controllers talk to each other
  • Storyboards give you a complete look at the flow of your application that you can never get from individual nib files floating around.
  • A reducer of all the "clutter" that happens when you have several controllers each with it's own nib file.

I have been using Storyboards for awhile now and the ONLY downside is that you can't target iOS 4 or below. Storyboards only work on devices running iOS 5 or better. Other than that, the benefits are many and the downsides are non-existent IMO.

The best tutorial I have seen is Ray Wenderlich's

Also, if you are a member of the Apple Developer program, check out last years WWDC session on Storyboards (iTunesU), it is awesome.

Another great one (also on iTunesU) is the latest Stanford iOS Application Programming course.

like image 163
LJ Wilson Avatar answered Sep 29 '22 06:09

LJ Wilson


There are not only pro sides of Storyboarding, also cons - just because you asked for input:

  • it's not easy to work with SBs in a team, since only one participant can work on the SB at once (because it's one file).

-The following is not true: - if you need to do things SB doesn't offer, it's not quite easy to get SB mixed with programatical created views (well, it is possible though)

The rule of thumb seems to be: the more complex you expect your project to get, the more you'll better not go for SB.

EDIT: - another disadvantage of SB: working around all the annoying bugs of XCode regarding SB. E.g. having to frequently flush the DerivedData folder because of several inconsistencies. Sometimes storyboard files or the link to them get corrupted. Then you might have the joy to search for the problem. Take a look at this thread to get the idea

EDIT 2 (March 2013): meanwhile Storyboards and Xcode are working much better, and documentation and best practices are wide spread. I think working with storyboard can be recommended for a majority of projects, even if there are still some glitches.

EDIT 3 (Sept 2013): now with the new Xcode 5 format working in teams with SB might get even better, as it seems to become possible to merge SB-code much easier now.

Another EDIT: well, if you have an hour of time, sit back, relax and listen to these guys discussing this topic (Ray Wenderlich & Co)

Edit 2016.1: after a long time being a Storyboard advocate, I had so much hassle with it the last months, that I decided to abandon Storyboards as far as possible. The reason for that is that Apple adds feature like stupid, but doesn't care about the bugs and the flaws. The performance having a lots of auto layout constraints is really bad (while design time), and the error-prone-ness has become huge. Example: even less complex Storyboards tend to get into a 'dirty mode' right after opening a project in Xcode (see git state). Tip: as a beginner you will love Storyboards since you can prototype quickly and get things running without lots of code. As you enter an intermediate state, you'll add more GUI code to your project. Now you start going back and forth between code and SB - and things start working out worse. Sooner or later you'll tend to do most of the GUI stuff in code, because the result is more predictable than having several sources.

like image 41
brainray Avatar answered Sep 29 '22 05:09

brainray