Search code examples
iosscrolltableviewfooterviewwillappear

infinite scroll in tableview using footer


I am trying to support infinite scroll in tableview. I know tableview lets scroll infinitely, but my case is different.

Initially, I will load 30 items in my tableview as the user scrolls down close to 30th element, I will make a http request to get next 30 items so its not like I am loading 60 items at once.

My way about going to do this is when my table is initally filled with 30 items, once the footerview is seen, then I will request the next 30 items.

My question is how to detect footerview is seen? Is there something like 'will appear' for just footerview?

Let me know if there is other better way of completing my scenario above

Thanks!!


Solution

  • A UITableView is a subclass of UIScrollView, and UITableViewDelegate conforms to UIScrollViewDelegate.

    So you can set yourself as the tableViewDelegate and implement scrollViewDidScroll:. You can then either check the scrollView.contentOffset yourself, or call [myTableView visibleCells]. I am sure there are various other methods as well.