How can I detect when a UITableView
has been scrolled to the bottom so that the last cell is visible?
I found this solution:
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let contentOffsetMaxY: Float = Float(scrollView.contentOffset.y + scrollView.bounds.size.height)
let contentHeight: Float = Float(scrollView.contentSize.height)
let lastCellIsVisible = contentOffsetMaxY > contentHeight + somePaddingIfWanted
if lastCellIsVisible {
doSomething()
}
}