Beginning Storyboards in iOS 5 Part 2
If you want to learn more about the new storyboarding feature in iOS 5, you’ve come to the right place!
In the , we covered the basics of using the new storyboard editor to create and connect various view controllers, along with how to make custom table view cells directly from the storyboard editor.
In this second and final part of the tutorial series, we’ll cover segues, static table view cells, the add player screen, and a game picker screen!
We’ll start where we left off last tutorial, so open your project from last time, or go through the first.
OK, let’s dive into some of the other cool new features in Storyboarding!
Introducing Segues
It’s time to add more view controllers to our storyboard. We’re going to create a screen that allows users to add new players to the app.
Drag a Bar Button Item into the right slot of the navigation bar on the Players screen. In the Attributes Inspector change its Identifier to Add to make it a standard + button. When you tap this button we’ll make a new modal screen pop up that lets you enter the details for a new player.
Drag a new Table View Controller into the canvas, to the right of the Players screen. Remember that you can double-click the canvas to zoom out so you have more room to work with.
Keep the new Table View Controller selected and embed it in a Navigation Controller (in case you forgot, from the menubar pick EditorEmbed InNavigation Controller).
Here’s the trick: Select the + button that we just added on the Players screen and ctrl-drag to the new Navigation Controller:
Release the mouse button and a small popup menu shows up:
Choose Modal. This places a new arrow between the Players screen and the Navigation Controller:
This type of connection is known as a segue (pronounce: seg-way) and represents a transition from one screen to another. The connections we had so far were relationships and they described one view controller containing another. A segue, on the other hand, changes what is on the screen. They are triggered by taps on buttons, table view cells, gestures, and so on.
The cool thing about using segues is that you no longer have to write any code to present the new screen, nor do you have to hook up your buttons to IBActions. What we just did, dragging from the Bar Button Item to the next screen, is enough to create the transition. (If your control already had an IBAction connection, then the segue overrides that.)
Recent Comments