重新加载 UITableView 数据的更可靠方法是什么? [英] What is More reliable way to reload UITableView Data?
本文介绍了重新加载 UITableView 数据的更可靠方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找到了 2 个函数来重新加载我的 UITableView 行
I have found 2 functions to reload my rows of UITableView
第一个.
[tableView reloadRowsAtIndexPaths:[tableView indexPathsForVisibleRows]
withRowAnimation:UITableViewRowAnimationNone];
第二.
[tableView reloadData];
重新加载 UITableView 数据的更具体方法是什么
What is more specific way to reload UITableView Data
推荐答案
这个回答可能有两种情况,
This answer may have two cases,
a) 您的表格至少有一个部分(带有标题或返回部分的视图)
a) You've the table with at least a single section (with a title or returning a view for section)
- 在这种情况下,如果您调用
reloadData
那么它也会重新加载部分.但是reloadRowsAtIndexPaths:withRowAnimation:
只会重新加载可见单元格,而不是部分.
- In this case, if you call
reloadData
then it'll also reload section too. ButreloadRowsAtIndexPaths:withRowAnimation:
will only reload the visible cells and not the section.
b) 你的表格至少有一个部分(没有标题或返回部分的视图)
b) You've the table with at least a single section (without a title or returning a view for section)
- 在这种情况下,如果您调用
reloadData
或reloadRowsAtIndexPaths:withRowAnimation:
两者都将仅重新加载可见单元格.
- In this case, if you call
reloadData
orreloadRowsAtIndexPaths:withRowAnimation:
both will reload only the visible cells.
哪一个更好?
- 正如我所解释的,根据情况,您应该调用任何一种方法.如果您有不想重新加载的部分,那么您应该调用
reloadRowsAtIndexPaths:withRowAnimation:
方法.或者,如果您想与部分一起重新加载单元格,则应调用reloadData
方法.
- As I explained, based on the case, you should call any of the one method. If you have sections which you don't want to reload then you should call
reloadRowsAtIndexPaths:withRowAnimation:
method. Or if you want to reload cells along with section then should callreloadData
method.
这篇关于重新加载 UITableView 数据的更可靠方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文