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.
Ok, I got it.
The "Adjust Scroll View Insets" was marked on my viewController (not my tableView).
Here is an answer with a detailed explanation
In my case tableView was created programmaticaly and I had to set tableView.estimatedRowHeight
to make the space disappear
@urgentx's answer did most of what I wanted but didn't get all the way there. I'm in a similar situation (upside down UITableView for a chat app) however their suggestion fully disables safe area behavior which isn't desirable on devices like the iPhone X because it means the tableview will be clipped by both the home indicator and any top navigation bars.
I did the following in order to make the tableview still correctly avoid safe areas while inverted:
override func viewDidLoad() {
super.viewDidLoad()
self.automaticallyAdjustsScrollViewInsets = false
self.tableView.contentInsetAdjustmentBehavior = .never
}
and then:
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
//fetch the safe area in layoutSubviews since this it's possible that they can change when the device is rotated
let safeArea = self.tableView.safeAreaInsets
//insets are **flipped** because the tableview is flipped over its Y-axis!
self.tableView.contentInset = .init(top: safeArea.bottom, left: 0, bottom: safeArea.top, right: 0)
}
This in essence replicates contentInsetAdjustmentBehavior = .automatic
behavior but with the insets flipped across the Y-axis.
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.
This is how it can be fixed easily through Storyboard (iOS 11):
Select Table View > Size Inspector > Content Insets: Never
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With