简体   繁体   English

更新UITableView中的所有单元格

[英]Update all cells in a UITableView

I have a method that I want to run on every cell in my UITableView, which would update a property in each cell (and the display would consequently reflect the change). 我有一种方法要在UITableView中的每个单元上运行,该方法将更新每个单元中的属性 (因此显示结果将反映更改)。 How can I do this? 我怎样才能做到这一点?

The "cell" shouldn't really hold any information so you don't really update a cell. “单元格”实际上不应保存任何信息,因此您不会真正更新单元格。

You update the data model (ie the array or whatever) that you are using to store data that then gets displayed in the table. 您更新用于存储数据的数据模型(即数组或其他),然后将其显示在表中。

Then when you want to "update the cells" you just update the data model data and then reload the table with... 然后,当您要“更新单元格”时,只需更新数据模型数据,然后用...重新加载表即可。

[self.tableView reloadData];

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

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