更新时间:2022-01-28 07:34:54
这个答案似乎不再适用了,因为自编写答案以来对UITableView实现进行了一些更改。看到此评论:在UITableView完成后收到通知询问数据?
This answer doesn't seem to be working anymore, due to some changes made to UITableView implementation since the answer was written. See this comment : Get notified when UITableView has finished asking for data?
我一直在玩这个问题几天,并认为继承 UITableView
的 reloadData
是***的方法:
I've been playing with this problem for a couple of days and think that subclassing UITableView
's reloadData
is the best approach :
- (void)reloadData {
NSLog(@"BEGIN reloadData");
[super reloadData];
NSLog(@"END reloadData");
}
reloadData
在表完成重新加载其数据之前没有结束。因此,当第二个 NSLog
被触发时,表视图实际上已经完成了对数据的询问。
reloadData
doesn't end before the table has finish reload its data. So, when the second NSLog
is fired, the table view has actually finish asking for data.
我是子类 UITableView
将方法发送到 reloadData
之前和之后的委托。它就像一个魅力。
I've subclassed UITableView
to send methods to the delegate before and after reloadData
. It works like a charm.