我不能像使用 UITableView
那样任意出列单元格来计算高度。使用 UICollectionView
执行此操作的等效方法是什么?
dequeueResuableCellWithReuseIdentifier:forIndexPath
正在调用 sizeForItemAtIndexPath
。作为返回,调用 dequeueResuableCellWithReuseIdentifier:forIndexPath
等。
我在 sizeForItemAtIndexPath
中调用 dequeueResuableCellWithReuseIdentifier:forIndexPath
以便能够检索单元格的高度。我的 Storyboard中有许多不同的单元格大小。
最佳答案
您的逻辑是错误的,sizeForItemAtIndexPath
只应在动态调整单元格大小(即修改 Interface Builder 中指定的大小,无论是 Storyboard还是 xib)时实现。
如果您的单元格的大小都来自界面构建器,那么您就不需要实现该方法。
关于iphone - 调用 dequeueReusableCellWithReuseIdentifier forIndexPath 会导致无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19091283/