Hi I have a TableViewController
with two static cells, however when displayed, it shows the two static cells, and then all the other empty cells for the tablevi
tableView.tableFooterView = UIView.init(frame: CGRect.zero)
Call this code in viewDidLoad
method.
You can achieve this also in Storyboard by simply dragging a view into the table view's footer area, and then set its height and background color to 1 and clear respectively using the property inspector.
(This assumes that you either can't or don't want to just use the Group style setting for some reason. Otherwise, just do that.)
Simply add:
tableView.tableFooterView = UIView()
Explanation:
This is totally valid and works perfectly in swift 3.By Since you are setting an empty UIView() object to the property, Setting tableFooterView to UIView() removes the rows.
Select your UITableView, go to the attribute inspector and change the style to Grouped.
in your viewDidLoad()
function add this line of code:
tableView.tableFooterView = UIView()
Abobe anwer is right. We can achieve this by adding
tableView.tableFooterView = UIView() // to remove extra cells in tableView