How can I detect when a UITableView
has been scrolled to the bottom so that the last cell is visible?
I had some problems with the willDisplayCell method. This works for me:
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let y = scrollView.contentOffset.y/(scrollView.contentSize.height - scrollView.frame.size.height)
let relativeHeight = 1 - (table.rowHeight / (scrollView.contentSize.height - scrollView.frame.size.height))
if y >= relativeHeight{
print("last cell is visible")
}
}
Just pass this in the delegate methods, and change 'table' to your tableView.