The Mother of Joseph Beuys The Mother of Joseph Beuys - 3 months ago 16
Swift Question

Detect when UITableView has scrolled to the bottom

Is the following post still the accepted way of detecting when an instance of UITableView has scrolled to the bottom [in Swift], or has it been altered (as in: improved) since?

Problem detecting if UITableView has scrolled to the bottom

Thank you.

Answer

try this

func scrollViewDidScroll(scrollView: UIScrollView) {
    let  height = scrollView.frame.size.height
    let contentYoffset = scrollView.contentOffset.y
    let distanceFromBottom = scrollView.contentSize.height - contentYoffset
    if distanceFromBottom < height {
        print(" you reached end of the table")
    }
}

or you can find in this way

 if tableView.contentOffset.y >= (tableView.contentSize.height - tableView.frame.size.height) {

        //you reached end of the table
    }