Reputation: 2574
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 :
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...).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 ?
Upvotes: 1
Views: 775
Reputation: 110
I do faced the same issue and finally figured out a solution,
I started animating the activity indicator in ViewDidLoad and made it Hidden,
[self.activityIndicator startAnimating];
self.activityIndicator.hidden = YES;
and in
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
while fetching datas make
self.activityIndicator.hidden = NO;
and when fetching is done make
self.activityIndicator.hidden = YES;
Hope this one helps
Upvotes: 2
Reputation: 2251
2nd approach is ok..but after you fetch new data just change the contentOffset
of tableView
manually to show the data below.
Upvotes: 2