What Are the Benefits of Using Storyboards Instead of Xib Files in iOS Programming

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

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.

When to use Storyboard and when to use XIBs

I have used XIBs extensively and completed two projects using Storyboards. My learnings are:

  • Storyboards are nice for apps with a small to medium number of screens and relatively straightforward navigation between views.
  • If you have lots of views and lots of cross-navigation between them the Storyboard view gets confusing and too much work to keep clean.
  • For a large project with multiple developers I would not use Storyboards because you have a single file for your UI and cannot easily work in parallel.
  • It might be worth for large apps to split up into multiple storyboard files but I have not tried that. This answer shows how to do segues between storyboards.
  • You still need XIBs: In both of my Storyboard projects I had to use XIBs for custom table cells.

I think Storyboards are a step in the right direction for UI implementation and hope Apple will extend them in future iOS versions. They need to resolve the "single file" issue though, otherwise they won't be attractive for larger projects.

If I start a small size app and can afford iOS5 only compatibility, I would use Storyboards. For all other cases I stick to XIBs.

Which is more efficient way? StoryBoard or XIB?

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.

xcode-using-storyboards-and-xibs-versus-creating-views-programmatically

Using XIBs

Advantages:

  • You can quickly put together a UI

  • Straight-forward implementation for small apps with a minimal number of screens

  • You can have separate XIBs for different localizations (ie. languages or countries)

  • Great at laying out elements and visually spotting misalignments. It’s easy to make a slight adjustment to the layout

Disadvantages:

  • It’s difficult to merge conflicts when working in a team environment (hard to diff, merge and read)

  • Highly dynamic views are impossible to describe as a XIB

  • Performance wise, it’s slower than creating views through code because the xib needs to be read from the disk and analysed/parsed

  • XIBs lack customizations that you can do in code such as Quartz stuff (drop shadows, round corners)

  • Harder to debug (i.e. if you forget to make a connection in Interface Builder or make a wrong connection)

Storyboards

Advantages:

  • Storyboards are nice for apps with a small to medium amount of screens and the requirements for navigation is relatively straightforward between views

  • You can mock up the flow of an application without writing much, if any, code

Disadvantages:

  • Storyboards are not compatible with pre-iOS 5 so it makes supporting iOS 4.3 impossible

  • It’s hard to work in parallel in a team environment because everyone’s modifying the same file

  • Along the same lines, merging conflicted storyboards in GIT will be a pain

  • People have experienced bugs in Xcode with the usage of storyboards (eg. having to frequently flush the DerivedData folder because of inconsistencies)

What is the reason for storyboards?

Long story short, my understanding of storyboard purpose is as follows:

  • Less code -> less bugs
  • Visual representation of UI layout simplifies UI creation (views hierarchy, autolayout constraints)
  • Extremely simple way to set objects' properties (e.g. delegates, gesture recognizers) just by control-drag

Storyboards vs. the old XIB way

There are things you can do with a storyboard that you can't do with a nib. A storyboard lets you create segues between view controllers, and it lets you design table view cells in-place.

There are things you can do with a nib that you can't do with a storyboard. In a nib, you can create references to the File's Owner placeholder. You can create multiple top-level views, edit them, and create connections between them. See this answer for an example of why you'd want to do that. You can add external object placeholders (a rarely-used feature).

Storyboards have the drawback that they collect a bunch of different, loosely-related objects into one big file. If you're working on a project with several developers, you are much more likely to run into merge conflicts if you're using a storyboard than if you're using xib files.

You should definitely learn about nibs at some point. Whether you want to start with them or start with a storyboard is probably not too important. Just find some tutorials you like and work through them with whichever type of file (nib or storyboard) they use.

Pros and cons of using storyboards

When to use Storyboard and when to use XIBs

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

iphone-sdk-development

I think these links are helpful and related to your question. Personally, I believe storyboards are better then nibs because they eliminate the need to code your transitions between views (unless you use custom transition with CA), and they have all the capabilities of nib files too.

Hope this helped.

-----------EDIT-----------

Here are some more links I found:

This one speaks about some of the cons of using storyboards.

UIStoryboard on iOS 5: The Good, The Bad, and the 'This Plain Sucks'

This one is mostly about the benefits.
What are the advantages of iOS 5.0 storyboarding over traditional UI layout?

IOS design from Storyboard or Code

It is as per the requirement. You can use anyone of them or do partially from both of them. Main motive of developer is to give best UI interaction to the user. You can go with any one of these which is suitable for you.

Have a look : What are the benefits of using Storyboards instead of xib files in iOS programming?

and

this user-interface-programming

You will get better better on this two links. If further you have issues and doubts you can ask.



Related Topics



Leave a reply



Submit