我正在开发一个 View Controller ,当用户滚动时会插入 Collection View 单元格。
我只在开始时使用 reloadData() 方法。 (viewDidLoad)
首次加载后,每当用户滚动时我都会使用 insertItems(at:) 方法。
需要添加很多单元格,因此单元格应该是可重复使用的。
但是我想知道当我直接插入单元格时是否会重复使用单元格。
插入单元格后是否会重复使用? (不是重新加载数据)
最佳答案
简短回答:是的,单元格可以重复使用。
更长的答案:
当您调用dequeueReusableCell(withReuseIdentifier:for:)
时要获取 Collection View 中某个项目的单元格,它将返回一个由其标识符定位的可重用单元格对象。
Call this method from your data source object when asked to provide a new cell for the collection view. This method dequeues an existing cell if one is available or creates a new one based on the class or nib file you previously registered.
关于ios - 插入 Collection View 单元格后是否可以重复使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58759187/