How to remove extra empty cells in TableViewController, iOS - Swift
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Extra empty rows at the bottom of a UITableView are a common UIKit annoyance. They appear because the table view keeps drawing separator lines and cell slots even when the data source has no more real rows to show.
The standard fix is simple: assign an empty footer view so the table stops displaying those unused cells. This is one of the easiest UIKit polish improvements you can make.
Use an Empty Footer View
The most common solution is:
That tells the table view there is nothing meaningful after the last real row, so the extra empty cells are no longer drawn.
This works in UITableViewController and in ordinary view controllers that own a table view.
Why This Works
Without a footer view, the table tries to fill remaining vertical space using its default empty rows and separators. By adding a footer view, even an empty one, you replace that default area with something intentional.
It is a small API detail, but it is the normal UIKit answer to this problem.
Full Example in UITableViewController
If you run this with only a few items, the table will stop showing the unwanted empty rows below them.
Do Not Solve It by Faking More Data
A wrong approach is to try to hide the problem by pretending the table has more rows or by styling empty cells manually. That creates more complexity than necessary.
The footer-view fix is cleaner because it addresses the rendering behavior directly instead of distorting the data source.
Know When Empty Space Is Actually Fine
Not every table view should fill the entire screen visually. Sometimes empty space below a short list is perfectly acceptable. The issue is usually not the blank area itself, but the default separators and empty-row appearance that make the UI look unfinished.
An empty footer removes that noise while preserving a clean layout.
This Is a Presentation Fix, Not a Data Fix
The footer-view approach does not change the number of rows in the table. It only changes how the unused area below your real data is rendered, which is exactly why it is such a clean solution.
Common Pitfalls
- Forgetting that
tableFooterViewbelongs to the table view, not the controller. - Trying to fix the issue by adding fake rows to the data source.
- Confusing ordinary blank space with the actual problem of visible empty separators.
- Reapplying the fix repeatedly when one
viewDidLoadassignment is enough. - Looking for a storyboard-only trick when the programmatic footer assignment is the standard answer.
Summary
- Extra empty cells usually come from the table view's default rendering behavior.
- Set
tableView.tableFooterView = UIView(frame: .zero)to remove them. - This is the normal UIKit solution in
UITableViewControllerand other table setups. - Do not fake more rows just to hide the issue.
- The goal is not removing blank space, but removing the unwanted empty-row appearance.

