Detect when UITableView has scrolled to the bottom

uiscrollview detect scroll to end
uitableview scroll to bottom
uitableview scroll to bottom load more swift
uitableview scroll to bottom swift 4
rxswift uitableview load more
uitableview bottom refresh swift
uitableview detect scroll direction swift
how to make uitableview scroll smooth swift

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.

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
}

Update UITableView when user scrolls to end, Update UITableView when user scrolls to end (Swift) point your user will scroll down to the end and (unless you don't have anything else you need to do is implement the scrollViewDidScroll: delegate where you'd detect  I would prefer it if the table view could be scrolled to the bottom before it appears. I tried the scroll in viewWillAppear and viewDidLoad but in both cases the data has not been loaded into the table yet and both throw an exception. Any guidance would be much appreciated, even if it’s just a case of telling me what I have is all that is

Swift 3

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    if indexPath.row + 1 == yourArray.count {
        print("do something")
    }
}

Implementing Scroll to Bottom Event iOS, Say you want to determine if somebody has scrolled to the bottom of a UITableView is subclass of UIScrollView, so it has common delegate  This solution is only valid when there is 1 section. When there are more sections, then the rows in the left hand side need to be accumulated. @kjoelbro You got the entire indexPath handy. It works, but it is kind of ugly.. or it doesn't look right.

We can avoid using scrollViewDidScroll and use tableView:willDisplayCell

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    if indexPath.section == tableView.numberOfSections - 1 &&
        indexPath.row == tableView.numberOfRows(inSection: indexPath.section) - 1 {
        // Notify interested parties that end has been reached
    }
}

This should work for any number of sections.

TableView RxSwiftified way to detect Scroll reached at the bottom , way to detect tableview reached the bottom, I have seen the Rx Repo MARK: Table view delegate func tableView(tableView: UITableView,  UITableView load more when scrolling to bottom like Facebook application (8) Swift. Method 1: Did scroll to bottom. Here is the Swift version of Pedro Romão's answer. When the user stops scrolling it checks if it has reached the bottom.

In Swift 4

func scrollViewDidScroll(_ scrollView: UIScrollView) {
  let isReachingEnd = scrollView.contentOffset.y >= 0
      && scrollView.contentOffset.y >= (scrollView.contentSize.height - scrollView.frame.size.height)
}

If you implement expandable UITableView/UICollectionView, you may need to check scrollView.contentSize.height >= scrollView.frame.size.height

Detecting when UIScrollView is bouncing – Cyril Chandelier, Let's say you want to have your UI change when a scroll view is bouncing (or over-scrolling). Now let's detect when the scroll view is bouncing from the bottom: And because UITableView and UICollectionView inherit from  Detecting UITableView scrolling ; Check if a user has scrolled to the bottom ; UITableview not visible the last cell when scroll down ; Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

scrollViewDidScrollToTop:, The scroll view sends this message when it finishes scrolling to the top of the content. It might call it immediately if the top of the content is already shown. For the  When UITableView is scrolled, the section header gets left behind #3. timominous opened this issue May 22, 2013 · 22 comments. Scrolling the tableview up leaves the section header at the bottom of the frame of the header and doesn't scroll along with the tableview.

Problem detecting if UITableView has scrolled to the bottom, I'm using the following code to detect if I've reached the bottom of a UITableView - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if(self.tableView. How can I detect when a UITableView has scrolled all the way down &sol; up&quest; I've got a view that has 3 tableView's. One is the "Main Table View", and then I have an 'Answers Table View' and 'Percentage Table View'.

How to add Load More / Infinite Scrolling in iOS using Swift, 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  a) use normal vertical scrolling (just normal behaviour of a UITableView) b) Here's the tricky part: detect horizontal scrolling (swipes) within the UITableView to switch to the previous/next item Detail, eg. right-swipe = show Item No. 2 Detail, left swipe = show No. 4 Detail. I have written a custom UITableView and implemented

Comments
  • Thanks @Anbu.Karthik. I may well do. I am appalled that such primitive methods still have to be used in 2016, but so be it. What's preventing the engineers from introducing a "func scrollViewDidScrollToBottom" function?
  • Don't worry @Anbu.Karthik, I'm just moaning.
  • @Anbu.Karthik You answer helped me to determine table's scroll (end of table). It is the reason, I think.
  • This solution doesn't work if you have a header in the table.
  • I had to change the if condition to if distanceFromBottom <= height to get this to work nicely.
  • This solution is only valid when there is 1 section. When there are more sections, then the rows in the left hand side need to be accumulated.
  • This seems like the best answer to me
  • @kjoelbro You got the entire indexPath handy. You can easily determine where is the end of your tableview
  • if indexPath.section == COUNT_OF_SECTIONS - 1 { if indexPath.row + 1 == LAST_DATA_SET.count { print("do something")
  • It works, but it is kind of ugly.. or it doesn't look right. We would need something like didDisplay cell, but unfortunately there is nothing like that
  • I believe the tableView calls this method for every cell it loads initially. E.g. if there are 26 cells and it first loads 13, it will call this 13 times upon the first reloadData() call. Thus, if you have 13 cells and it loads 13, it will call willDisplay and you will get a false positive saying that the user reached the bottom. I believe... someone confirm please