我找到了两个函数来重新加载我的UITableView行
第一
[tableView reloadRowsAtIndexPaths:[tableView indexPathsForVisibleRows]
withRowAnimation:UITableViewRowAnimationNone];
第二。
[tableView reloadData];
重新加载UITableView数据的更具体方法
答案 0 :(得分:1)
两者都是“可靠的”,可能是“具体的”(具体取决于你的意思) - 事实上,还有更多的方法:
reloadData
reloadRowsAtIndexPaths:withRowAnimation:
reloadSections:withRowAnimation:
reloadSectionIndexTitles
检查开发人员文档(https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/index.html)中的差异,但简短的回答是它们都是可靠的 - 它只取决于您要重新加载的信息量,以及是否要使用动画。
例如,如果您只想重新加载某些行,则可以使用reloadRowsAtIndexPaths:withRowAnimation:
。如果您想重新加载整个部分,请使用reloadSections:withRowAnimation:
。
答案 1 :(得分:1)
这个答案可能有两种情况,
a)你在桌子上至少有一个部分(带有标题或返回部分视图)
reloadData
,那么它也会重新加载部分。但是reloadRowsAtIndexPaths:withRowAnimation:
只会重新加载可见的单元格而不是部分。b)你在桌子上至少有一个部分(没有标题或返回部分视图)
reloadData
或reloadRowsAtIndexPaths:withRowAnimation:
,两者都只会重新加载可见的单元格。哪一个更好?
reloadRowsAtIndexPaths:withRowAnimation:
方法。或者,如果您想要重新加载单元格,则应调用reloadData
方法。