简体   繁体   English

Xamarin iOS自定义UITableViewCell重用

[英]Xamarin iOS custom UITableViewCell reuse

I have multiple custom cells stored in .xib files that I use to populate a table with. 我在.xib文件中存储了多个自定义单元格,用它们来填充表。 I tried thinking of a way to implement cell reuse in this case, but the fact that each custom cell contains different fields (the data bound to it), I don't know how I could reuse them when I don't have the source to repopulate the fields... Every example I can find show it for a single type of cells if the table, or simply don't put data back in the cell when they "reuse" them. 我尝试过考虑在这种情况下实现单元重用的方法,但是事实是每个自定义单元都包含不同的字段(绑定到其上的数据),我不知道在没有源的情况下如何重用它们重新填充字段...如果找到表,我可以找到每个示例都针对一种类型的单元格进行显示,或者当它们“重用”它们时根本不将数据放回单元格中。

You dont "bind" data to cells if you want to use cell-reuse (object pooling). 如果要使用单元重用(对象池),则不要将数据“绑定”到单元。 Instead all data should be available outside each cell so each time GetCell() is called , if a cell becomes active again it can find all necessary data to populate the fields 相反,所有数据都应在每个单元格外部可用,因此每次调用GetCell()时,如果单元格再次变为活动状态,它可以找到所有必要的数据来填充字段

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

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