iOS Developer Library

Developer

UIKit Framework Reference UIStoryboard Class Reference

Options
Deployment Target:

On This Page
Language:

UIStoryboard

Inherits From


Conforms To


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 5.0 and later

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.

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

    Declaration

    Swift

    init(name name: String, bundle storyboardBundleOrNil: NSBundle?) -> UIStoryboard

    Objective-C

    + (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. If no storyboard resource file matching name exists, an exception is thrown with description: Could not find a storyboard named 'XXXXXX' in bundle....

    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.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later

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

    Declaration

    Swift

    func instantiateInitialViewController() -> AnyObject

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later

  • Instantiates and returns the view controller with the specified identifier.

    Declaration

    Swift

    func instantiateViewControllerWithIdentifier(_ identifier: String) -> AnyObject!

    Objective-C

    - (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 used only 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. If no view controller is associated with the string, this method throws an exception.

    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.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later