Member-only story

UIStoryboard iOS

Mr.Javed Multani
1 min readOct 5, 2020

--

A UIStoryboard object encapsulates the view controller graph stored in an Interface Builder storyboard resource file. This view controller graph represents the view controllers for all or part of your application’s user interface.

Getting an instance of UIStoryboard programmatically

SWIFT:

Getting an instance of UIStoryboard programmatically can be d

let storyboard = UIStoryboard(name: “Main”, bundle: nil)

where

name => the name of the storyboard without the extension
bundle => the bundle containing the storyboard file and its related resources. If you specify nil, this method looks in the main bundle of the current application.

For example, you can use the instance created above to access a certain UIViewController instantiated within that storyboard:

let viewController = storyboard.instantiateViewController(withIdentifier:z“yourIdentifier”)

OBJECTIVE-C:

Getting an instance of UIStoryboard in Objective-C can be done as follows:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@”MainStoryboard” bundle:nil];

Example of accessing UIViewController instantiated within that storyboard:

MyViewController *myViewController = [storyboard
instantiateViewControllerWithIdentifier:@"MyViewControllerIdentifier"];

--

--

Mr.Javed Multani
Mr.Javed Multani

Written by Mr.Javed Multani

Software Engineer | Certified ScrumMaster® (CSM) | UX Researcher | Youtuber | Tech Writer

No responses yet