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
  • PrintPrint
Share this Page URL
Help

Chapter 9: Creating Custom Cells with Su... > Building the Cell in Code with the c...

Building the Cell in Code with the contentView

Although this app is creating two custom subclasses of UITableViewCell, up to this point you've used the tried and tested nib-based approach to building and laying out the cell's contents.

In this example, you will go a bit further than swapping things around – in fact, what you will do is to recreated the planets-and-stars cells in code rather than using Interface Builder.

At a high level, the process looks like this:

  • Create a UITableViewCell subclass for each cell type (you will end up with one for EvenCell and one for OddCell)
  • Set up the subclasses with properties for the controls that will be set externally as the cells are created and updated
  • In the subclasses' initWithStyle:reuseIdentifier: method, create and add the various elements to the cell's contentView

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


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