reloadData only on tableView visible cells

泄露秘密 提交于 2019-11-27 21:14:40

问题


Is that possible? To reload only the cells that are visible in order to do it more efficient.


回答1:


That's how table views work by default. The UITableView class never loads cells until they're about to appear onscreen, even when you call reloadData.




回答2:


Try this, You can reload any cell of the tableview using reloadRowsAtIndexPaths:

[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows]
                 withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];



回答3:


To reload visible cells of tableview in Swift 3.0:

pTableView.beginUpdates()

pTableView.reloadRows(at:
pMessagesTableView.indexPathsForVisibleRows!, with: .none)

pTableView.endUpdates()


来源:https://stackoverflow.com/questions/4923388/reloaddata-only-on-tableview-visible-cells

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!