Hi, 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:
- show the indicator view
- make the web request
- hide the indicator view?
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];
}
}
}