I'm adding 'pull to load more' to a UITableView. I've got the reloading working and I can add more data, but I'm trying to display a UIActivityIndicatorView when the data loads. I've managed to get the current accessory to disappear, but I can't make the actitity indicator draw itself.
This is the code I have in my UITableViewCell subclass:
-(void) toggleLoading:(bool)showLoading {
if(showLoading) {
[self.accessoryView setHidden:true];
isLoading = false;
} else {
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.frame = CGRectMake(0, 0, 24, 24);
self.accessoryView = spinner;
[spinner startAnimating];
[spinner release];
isLoading = true;
[self.backgroundView setNeedsDisplay];
}
}
The method is called and when the data finishes loading, the correct accessory is shown aga开发者_JAVA百科in. Is there an extra step I need?
Shouldn't you be drawing the spinner in didSelectRowAtIndexPath?
btw I would use:
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
Turned out I was trying to call this from a separate thread (using GCD), hence the lag in updating the UI. The solution was to move the UI calls onto the UI thread.
精彩评论