Customize that UIViewCell – Part 1: Using Interface Builder
Tuesday, July 21st, 2009If you followed my first tutorial on UITableView (link | source code), you now have a very simple app that shows a list of DVD titles and clicking any of the titles shows you a detail view page with more information about the DVD. That’s all nice but we really want to make it a little bit prettier. We could display the length of each movie right on the listing page. Also, we have this coverImage field in our data set, let’s use it.
What we want is for our home screen to look like this:
We can accomplish that by customizing UITableViewCell. There are 2 ways of going about it:
- Using Interface Builder
- Programmatically
In reality, you can also choose a hybrid approach where you create some UI elements in the Interface Builder and some programmatically.
Which option to choose?
The two approaches both bring some advantages and disadvantages with them.
Interface Builder
If you decide to go the Interface Builder route, you’ll find it very easy to create and customize your cells. Any subsequent edits can also be done quite easily since you’re simply rearranging elements visually. The downside is speed and performance since the system needs to render each view in a cell individually. If your table view has thousands of rows in it, this may/may not affect the performance of your app, depending how complicated your cell is.
Programmatically
This one involves a lot more work. You are responsible for creating each UI element by hand in the code. That can be very tedious and any edits you need to make in the future require code changes. Also, you’ll need to set up all the autosizing masks yourself. The upside is performance. Since the system will draw each cell as one view, the performance gain can be very significant.


