How to remove extra empty cells in TableViewController, iOS - Swift
Solution 1:
in your viewDidLoad()
function add this line of code:
tableView.tableFooterView = UIView()
Solution 2:
Select your UITableView, go to the attribute inspector and change the style to Grouped.
Solution 3:
To add to this, the reason why setting tableFooterView
to UIView()
removes the rows is because you are setting an empty UIView()
object to the property. As per the Apple documentation:
var tableFooterView: UIView?
Therefore setting an empty UIView() will display nothing below your data for this property.
You can bring the empty rows back by resetting tableFooterView
to the default value, like so:
tableView.tableFooterView = nil