Graphics Programs Reference
In-Depth Information
Segues
Most iOS applications have a number of view controllers that users navigate between. St-
oryboards allow you to set up these interactions as segues without having to write code.
A segue moves another view controller onto the screen when triggered and is represented
by an instance of UIStoryboardSegue . Each segue has a style, an action item, and an
identifier. The style of a segue determines how the view controller will be presented, such
as pushed onto the stack or presented modally. The action item is the view object in the
storyboard file that triggers the segue, like a button, a bar button item, or another UICon-
trol . The identifier is used to programmatically access the segue. This is useful when you
want to trigger a segue that doesn't come from an action item, like a shake or some other
interface element that can't be set up in the storyboard file.
Let's start with two push segues. A push segue pushes a view controller onto the stack of a
navigation controller. We'll need to set up two more view controllers in our storyboard, one
whose view's background is red, and the other, white. The segues will be between the table
view controller and these two new view controllers. The action items will be the table
view's cells; tapping a cell will push the appropriate view controller onto the navigation
controller's stack.
Drag two UIViewController s onto the canvas. Select the View of one of the view
controllers and, in the attributes inspector, change its background color to red.
Next, select the cell titled Red . Control-drag to the view controller whose view has the red
background. A black panel titled Storyboard Segues will appear. This panel lists the pos-
sible styles for this segue. Select Push .
Then, select the White cell and Control-drag to the other view controller. Your canvas
should look like Figure 24.12 .
Figure 24.12 Setting up two segues
 
Search WWH ::




Custom Search