Using ItemCell

Let’s get your custom cells onscreen. In ItemsViewController’s tableView(_:cellForRowAtIndexPath:) method, you will dequeue an instance of ItemCell for every row in the table.

Now that you are using a custom UITableViewCell subclass, the table view needs to know how tall each row is. There are a few ways to accomplish this, but the simplest way is to set the rowHeight property of the table view to a constant value. You will see another way later in this chapter.

Open ItemsViewController.swift and update viewDidLoad() to set the height of the table view cells.

override func viewDidLoad() { super.viewDidLoad() // Get the height of the status bar let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.height ...

Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.