reloadData only on tableView visible cells

2020-02-09 04:12发布

问题:

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()