UIStoryboard Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 5.0 and later.
Companion guide
Declared in
UIStoryboard.h
Related sample code

Overview

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. Normally, view controllers in a storyboard are instantiated and created automatically in response to actions defined within the storyboard itself. However, you can use a storyboard object to instantiate the initial view controller in a storyboard file or instantiate other view controllers that you want to present programmatically.

Tasks

Getting a Storyboard Object

Instantiating Storyboard View Controllers

Class Methods

storyboardWithName:bundle:

Creates and returns a storyboard object for the specified storyboard resource file.

+ (UIStoryboard *)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil
Parameters
name

The name of the storyboard resource file without the filename extension. This method raises an exception if this parameter is nil.

storyboardBundleOrNil

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.

Return Value

A storyboard object for the specified file or nil if no such object exists.

Discussion

Use this method to retrieve the storyboard object containing the view controller graph you want to access. All of the resources associated with the storyboard must be in the bundle indicated by the storyboardBundleOrNil parameter.

Availability
  • Available in iOS 5.0 and later.
Related Sample Code
Declared In
UIStoryboard.h

Instance Methods

instantiateInitialViewController

Instantiates and returns the initial view controller in the view controller graph.

- (id)instantiateInitialViewController
Return Value

The initial view controller in the storyboard.

Discussion

Every storyboard file must have an initial view controller that represents the starting point for the corresponding user interface. For an application’s storyboard, this is usually the first screen presented to the user at launch time. You designate the initial view controller in Interface Builder when configuring the storyboard file.

Typically, you use this method only when transitioning to the initial view controller in a different storyboard file. For your application’s main storyboard file—that is, the storyboard file specified in the application’s Info.plist file using the UIMainStoryboardFile key—the initial view controller is loaded and presented automatically.

This method creates a new instance of the initial view controller each time you call it.

Availability
  • Available in iOS 5.0 and later.
Declared In
UIStoryboard.h

instantiateViewControllerWithIdentifier:

Instantiates and returns the view controller with the specified identifier.

- (id)instantiateViewControllerWithIdentifier:(NSString *)identifier
Parameters
identifier

An identifier string that uniquely identifies the view controller in the storyboard file. You set the identifier for a given view controller in Interface Builder when configuring the storyboard file. This identifier is not a property of the view controller object itself and is only used by the storyboard file to locate the view controller.

If the specified identifier does not exist (or is nil) in the storyboard file, this method raises an exception.

Return Value

The view controller corresponding to the specified identifier string or nil if no view controller is associated with the string.

Discussion

You use this method to create view controller objects that you want to manipulate and present programmatically in your application. Before you can use this method to retrieve a view controller, you must explicitly tag it with an appropriate identifier string in Interface Builder.

This method creates a new instance of the specified view controller each time you call it.

Availability
  • Available in iOS 5.0 and later.
Related Sample Code
Declared In
UIStoryboard.h