I've got a UITableView with several entries. Upon selecting one, I need it to do a potentially time-consuming network operation. To give the user some feedback, I tried to place a UIActivityIndicatorView in the UITableViewCell. However, the spinner doesn't appear until much later -- after I've done the expensive operation! What am I doing wrong?
- (NSIndexPath *) tableView:(UITableView *) tableView
willSelectRowAtIndexPath:(NSIndexPath *) indexPath {
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[spinner autorelease];
[spinner startAnimating];
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryView:activity];
if ([self lengthyNetworkRequest] == nil) {
// ...
return nil;
}
return indexPath;
}
As you can see, I have the spinner being set to the accessoryView before the lengthy network operation. But it only appears after the tableView:willSelectRowAtIndexPath:
method finishes.