我有一个UITableView与几个条目。选择一个,我需要它做一个潜在的耗时的网络操作。为了给用户一些反馈,我尝试在UITableViewCell中放置一个UIActivityIndicatorView。然而,微调不会出现,直到很久以后 - 我完成了昂贵的操作之后!我究竟做错了什么?UITableViewCell accessoryView不会出现,直到很晚
- (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;
}
正如您所看到的,我在长时间的网络操作之前将微调器设置为accessoryView。但只有在tableView:willSelectRowAtIndexPath:
方法结束后才会出现。