简体   繁体   English

queueReusableCellWithReuseIdentifier在Xcode中做什么?

[英]What does queueReusableCellWithReuseIdentifier do in Xcode?

I am working with open source iOs app and came across this: 我正在使用开源iOs应用程序,并且遇到了以下问题:

queueReusableCellWithReuseIdentifier queueReusableCellWithReuseIdentifier

How do you use this? 你怎么使用这个? I kind of think I may have an idea of it - perhaps it is a variable that is passed through multiple times? 我认为我可能对此有所了解-也许它是一个多次传递的变量? Do you use it each time? 每次都用吗? I'm a beginner, so any help will be appreciated. 我是一个初学者,所以我们将不胜感激。 Thank you so much! 非常感谢!

Think about all the cell of a table view exists in an array of cells. 想一想表视图中的所有单元格都存在于一组单元格中。

Once the table view wants to load a cell it calls this method with the indexPath (to insert it into the right index) and identifier to recognise the cell (if you have multiple cells) 表格视图要加载单元格后,便会使用indexPath(将其插入到正确的索引中)和用于识别该单元格的标识符(如果您有多个单元格)调用此方法

Now, if the this method return nil. 现在,如果此方法返回nil。 Then the "array of cells" does not contains a cell that can be reused, and the a cell needs to be initialised. 然后,“单元格阵列”不包含可以重用的单元格,并且该单元格需要初始化。

This method if for performance issues mainly, so you will not have to instantiate a instance of a cell every time you want to load a cell. 该方法主要用于性能问题,因此您不必在每次要加载单元时都实例化该单元的实例。

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

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