[tableView reloadData]是否会影响ios的性能?什么是[tableView reloadData]?它是如何重新加载表视图的?有没有其他方法可以重新加载tableview?
我想在表视图的末尾添加一些行。我该怎么做呢?
它们之间的区别是什么
[self.tableView reloadData] 和
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:insertIndexPathswithRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];发布于 2012-10-04 20:00:57
reloadData正是这样做的--完全更新表视图(可见部分)。
如果您只需要更新某些单元格,即更新、插入、移除或移动,请使用适当的更新方法。这甚至会使变化变得生动起来。
发布于 2012-10-04 20:01:22
如果你的数据已经完全改变,并且你想要显示最新的版本(或者可能过滤器已经改变了等等),self.tableView reloadData更多的是被使用。
例如,假设你有一个显示足球运动员的表格,你“按下开关”来显示来自不同球队的足球运动员。在这种情况下,您可能倾向于使用reloadData。这将刷新整个表。
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:insertIndexPathswithRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];用于将新数据添加到显示的当前数据集中。这不会刷新整个表格,但会将新行动画显示到当前表格中。
发布于 2012-10-04 20:15:22
如果要重新加载一个节或几行,也有一些方法可以做到这一点。
对于行:
[self.tableView reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation];对于横断面:
[self.tableView reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation];https://stackoverflow.com/questions/12726725
复制相似问题