Multiple Storyboards

I have developed many iOS apps from scratch having tens of screens in the app. As the number of screens grows, the management of those screens and the collaboration between the team members on design process turns out to be very painful(Resolving merge conflicts that are caused by storyboards can be a real pain). In order to increase the productivty and modularity while playing with those screens, organizing all screens with multiple storyboards for each feature of your app will ease your development.

Multiple Storyboards

Assume our app may have features such as Business Info, Request Driver, Bookings, History and etc. Each feature(or module) has its own dedicated set of screens. Using multiple storyboard approach, we will simply accumulate all screens, dedicated to a single feature, to a single storyboard.

Multiple Storyboards

When you create an Xcode project, you come up with a single storyboard named Main.storyboard. You can add a storyboard design from

New File > (iOS, watchOS, tvOS) > User Interface > Storyboard.

to each feature. Then you can add your View Controllers to each dedicated storyboard without worrying about the way how we refer to those storyboards.

Let’s we have a slide-out slider menu in our Main.storyboard that should be linked to all individual storyboards. Formerly you can do it programmatically depicted below:

@IBAction func onRequestDriverClicked(sender: UIButton)
{
    /* Name of the storyboard is given here */
    var storyboard = UIStoryboard(name: "RequestDriver", bundle: nil)
    var controller = storyboard.instantiateViewControllerWithIdentifier("RequestDriverController") as UIViewController
    
    self.presentViewController(controller, animated: true, completion: nil)
}

However, beginning with the iOS-9, Storyboard Reference is introduced which provides linking mechanism at the design stage. This new feature converts your single, fat and complex storyboard into modular and high-level storyboard easing your management.

Multiple Storyboards

To sum up, I strongly recommend you to organize your projects one storyboard for one feature approach because of the following reasons: easy management of feature designs and increase your team productivity by reducing conflicts

Further Readings

  • If you have an existing project, you should refactor the project by dividing it to multiple storyboards(XCode’s Refactor to Storyboard feature). You can refer to this tutorial

  • Refactoring Storyboards by Apple

comments powered by Disqus