Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 10: Storyboards > Dynamic Prototype Cells

Dynamic Prototype Cells

As you may recall from Chapter 8, iOS 5 lets you create a nib file containing a UITableViewCell and whatever objects you want the cell to contain, and use a unique identifier to register that cell with the table view. Then, at runtime, you can ask the table view to give you a cell based on an identifier, and if the identifier matches your earlier registration, that's what you'll get.

With storyboards, this concept is cranked up a notch. Now, instead of creating separate nib files for each type of cell, you can create them all in a single storyboard, directly inside the table view where they will be presented! Let's see how this is done.

Dynamic Table Content, Storyboard-Style

We're going to make a controller that displays a list of items. Depending on the content of each item, we'll display them with a fairly plain style or with a more eye-catching style to alert the users that they need to pay special attention to the item. Just to make things concrete, let's imagine these items are to-do list entries, and we want to alert the users to entries that are urgent. To keep things simple, we'll use a plain UITableViewCell for each displayable cell instead of defining any cell subclasses. For more complicated displays in a real app, you would probably want to create your own cell subclasses to use here. In either case, the setup and workflow are the same.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint