UITableView notes Jul 14 2019

There are small details of UITableView that are simple but makes the table view look good. One of those is hiding the separator for empty cells.

A table view has a header, body and footer. Most of the time, when we start a project, we drag a table view but never define the header and footer of the table view, we only use the body. The problem with not having a footer is that the body of the table fills the container, so empty cell separator shows. If we add a footer, even if it is an empty view, this does not occur any more. Let’s first see how to do it via code.

Creating the footer on code

We can add the footer view by code: (where ever you initialize your table view, here I used viewDidLoad for this):

override func viewDidLoad() {

        tableview.tableFooterView = UIView()

That prevents the body from repeating, and the cell separator of empty cells is not visible any more. Now let’s see how to do it using the Storyboard.

Creating the footer using Storyboard

If you want to add a header and a footer using Storyboard, you’ll need to:

  1. Go to your Object Library search for UIView
  2. Drag it to your UITableView, under your cells.
  3. (optional)Change the dimensions to height 0, so the footer doesn’t show.

Add footer to UITableView GIF

** There is no comment system yet, but you can send me a message on twitter @rderik or send me an email: derik[at]rderik[dot]com.