【发布时间】:2013-08-29 19:02:54
【问题描述】:
我有一个功能可以连接到互联网,然后刷新表格中的单元格。
我的功能是:
- (void) updateMethod
{
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
queue.name = @"Data request queue";
[queue addOperationWithBlock:^{
//neither of these delay the responsiveness of the table
[columnArrayBackground removeAllObjects];
[self getColumnDataBackground];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
for (int i=0; i < 6; i++) {
columnArray[i] = columnArrayBackground[i];
};
//THIS ONE LINE CAUSES DELAYS
[homeTable reloadData];
}];
}];
}
除了 [homeTable reloadData] 之外,一切都非常快速。当我对此发表评论时,我会迅速做出回应。当我取消注释时,我的细胞反应有时会滞后几秒钟!
我的其他 reloadData 调用不会延迟我的应用程序。我没有正确实现 NSOperationQueue 吗?
【问题讨论】:
-
您可以尝试仅重新加载可见单元格吗?如果您的数据源在用户向下滚动之前已更新,那么它可能会更快,例如 [homeTable reloadRowsAtIndexPaths:[homeTable indexPathsForVisibleRows]]
-
显示表视图委托方法。
getColumnDataBackground是做什么的?你怎么知道它导致了delay?
标签: ios objective-c performance uitableview nsoperationqueue