Member-only story
Create a CustomUITableViewCell in a UITableView
Tired cell?
Difficulty: Beginner | Easy | Normal | Challenging
Creating a custom UITableViewCell can be a little bit tricky when done from the storyboard — but this article is here to help you out!
The Project
The idea is to have a UIViewController
with a UITableView
, and be able to move once the UITableViewCell
is clicked move to a Detail UIViewController
.
For fun, this is going to display a well-chosen list of animals (just the obvious animals here: Dogs, Cats and Galapagos Giant Tortoises are of course included). The DetailViewController
will simply display the name of the animal in a UILabel
.
Setup: the basic classes for the UIViewController and UITableViewCell
The CustomTableViewCell
class looks like the following
Which is, as you might expect, a single line label when viewed in the storyboard
Which needs a storyboard identifier within the storyboard to be set — this will need to be set as cell if you follow along with the article.
The rest of the code for the ViewController
is as follows: