Search code examples
iosuitableviewtablefooterview

Set table view footer while loading need cells


I'm trying to add a UIActivityIndicatorView to the footerView of my UITableView.

I'm using - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView to detect when the user scrolls to the bottom, and I fetch new data, then reload the tableview.

I've tried two approach, and none fits what I want :

  1. Adding the activity indicator in the viewDidLoad method works fine, when I scroll down the indicator shows perfectly. But, when I only have like one or two rows : the indicator shows up (logic, but not what I want...).
  2. Adding the activity indicator in the scrollViewDidEndDecelerating methods, when I detect that I need to fetch new data (and remove it when I got the data). The problem is that the footer is displayed after the scroll is finished, meaning that the user doesn't see it (except if he scrolls again).

Any thoughts on a better solution ?


Solution

  • 2nd approach is ok..but after you fetch new data just change the contentOffset of tableView manually to show the data below.