简体   繁体   English

reloadData 仅在 tableView 可见单元格上

[英]reloadData only on tableView visible cells

Is that possible?这可能吗? To reload only the cells that are visible in order to do it more efficient.仅重新加载可见的单元格以提高效率。

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 . UITableView类永远不会加载单元格,直到它们即将出现在屏幕上,即使您调用reloadData

To reload visible cells of tableview in Swift 3.0:要在 Swift 3.0 中重新加载 tableview 的可见单元格:

guard let visibleRows = pTableView.indexPathsForVisibleRows else { return }

pTableView.beginUpdates()

pTableView.reloadRows(at: visibleRows, with: .none)

pTableView.endUpdates()

Try this, You can reload any cell of the tableview using reloadRowsAtIndexPaths:试试这个,您可以使用reloadRowsAtIndexPaths:重新加载 tableview 的任何单元格reloadRowsAtIndexPaths:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM