My tableview has an extra space at the bottom, as you see in the picture:
All the rows in the tableView have a fixed height of 71pt.
My problem didn't solve by the answers.
i had a UISearchbar
as tableHeaderView
which caused the white space ( i don't know why) . I removed the searchbar from tableview in storyboard and in viewWillLayoutSubviews
added in table header then problem solved.
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
tableView.tableHeaderView = searchBar
}
In my case this was due to having a footer of height 18 by default at the bottom of the UITableView. Setting it to 1 removed the extra space at the bottom.
I had the same issue, with latest Xcode (11.3) with latest iOS (13.3) iPhone. I tried many answers, but none worked.
My tableView
has top, bottom, leading, and trail constraints but somehow there is large space at bottom below the last cell. (tableView.contentSize.height
was almost double of what is needed) Data for tableView
is not dynamic at all.It happens both when the view controller that has it shows it and when tableView
is hidden then shown again.
I solved it by using scrollView's delegate method like below, so that when the user starts dragging, height is adjusted. For me, it works so great, hope for you, too!
// this is the best place to adjust the contentSize.height of tableView.
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
print("scrollViewWillBeginDragging():") // optional
// replace allParkingGeos.count with your data for tableView
tableView.contentSize.height = CGFloat(allParkingGeos.count) * cellHeight
}
In my case tableView was created programmaticaly and I had to set tableView.estimatedRowHeight
to make the space disappear
This is how it can be fixed easily through Storyboard (iOS 11):
Select Table View > Size Inspector > Content Insets: Never
In case there is an embedded navigation controller, checking "shows toolbar" creates bottom spacing in the view controller. Just uncheck it.