UIStoryboardSegue is the Cocoa Touch class for segues used in storyboards in iOS 5.0 and later. Segues represent the relationship between two different scenes (i.e. view controllers) on a storyboard, generally used for facilitating the transition between two scenes.
UIStoryboardSegue
is the Cocoa Touch class for segues in storyboards in iOS 5.0 and later. Segues represent the relationship between two different scenes (i.e. view controllers) on a storyboard, generally used for facilitating the transition between the two scenes.
Segue types
The two most commonly used action segues include:
Push segues: Used in conjunction with a navigation controller to push from one scene to another, useful for representing workflows that may consist of multiple levels of scenes; and
Modal segues: Used to present a new modal scene, often a self contained scene that must be dismissed before control returns to the presenting view controller and the main workflow of the app.
Show Detail segues: Used to present a scene in detail view controller of
UISplitViewController
. This way we can have multiply detail view scenes.
Less common action segues include:
Custom segues: Used to represent a new scene using a custom transition when the standard segues are unable to achieve the desired effect, e.g. a custom animation to perform in conjunction with a segue;
Unwind segues: In iOS 6 and higher, an unwind segue can be defined that lets the application unwind one or more segues back to a particular scene, achieved by defining (a) defining an unwind action in one of the preceding view controllers; and (b) creating a segue from a control in a scene to the "exit" outlet in the bar below its scene. Unwind segues are not represented visually on the storyboard, but nonetheless offer an easy and flexible way of jumping back levels, dismissing and popping the intervening scenes as appropriate.
There are other segue types, including:
Embed segues: When using custom container views in iOS 6 or higher, an embed segue represents the relationship between a parent view controller and its child view controller;
Replace segues: When targeting an iPad and using a split-view controller, you can also define a replace segue that replaces one of the splits (either the "master" or the "detail") with a new scene; and
Popover segues: When targeting an iPad, a popover segue can be used to present a popover view (with its own view controller).
Optional segue-related methods
When using segues, to set a property in the destination controller, write a prepareForSegue
method. In iOS 6 or later, one can also write a shouldPerformSegueWithIdentifier
method which can apply conditional logic to determine whether a particular segue should be performed or not.
To programmatically perform a segue, the performSegueWithIdentifier
method may be invoked.