Reputation: 3315
i'm trying to get a UIActivityIndicatorView to "appear and animate" when a user scrolls to the bottom of a UITableView….
Upon reaching the bottom of the table view, a web-request is made that will take a few seconds to complete and then the UIActivityIndicatorView should "stop and hide"
I'm triggering the appearance of the UIActivityIndicatorView using tableView:willDisplayCell:forRowAtIndexPath:
List item
But the problem is that the UIActivityIndicatorView doesn't appear on the iPhone screen until after the entire method (i.e., tableView:willDisplayCell:forRowAtIndexPath:) is called, and by then it's also already hidden.
Any ideas as to how to:
new thread? better way?
Thanks!!
specifically, my function looks like this
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.results && indexPath.row == [self.results count] - 1) {
[self.loadingSignal setHidden:NO]; // <====== my UIActivityIndicatorView is called "loadingSignal"
[self.loadingSignal startAnimating];
/// make web request that will take a few seconds
[self.loadingSignal setHidden:YES];
[self.loadingSignal stopAnimating];
}
}
}
Upvotes: 1
Views: 680
Reputation: 16653
You can try doing so in the cellForRowAtIndexPath: method of the UITableView
Upvotes: 1
Reputation: 6043
Okay. From your above snippet of code, I see a few problems:
willDisplayCell
method.Here's how I think you should solve this problem:
[tableView reloadData]
This should allow you to achieve what you want to do.
Upvotes: 1