gpt4 book ai didi

ios - UICollectionViewLayout 何时调用 layoutAttributesForItemAtIndexPath

转载 作者:技术小花猫 更新时间:2023-10-29 11:23:49 25 4
gpt4 key购买 nike

我正在对 UICollectionViewLayout 进行子类化,并且永远不会调用 layoutAttributesForItemAtIndexPath: 方法。

我也知道要覆盖 layoutAttributesForElementsInRect:,但我宁愿不必处理矩形,因为如果我只处理索引路径,它会简单得多。

如果 layoutAttributesForItemAtIndexPath: 从未被调用,那有什么意义呢?

最佳答案

layoutAttributesForItemAtIndexPath: 在不同的场景中被调用,当您向 Collection View 添加新单元格时,当您更改布局时,当您重新加载特定索引路径时,等等。

您需要实现它,即使它不会在“默认”场景中被调用。

关于ios - UICollectionViewLayout 何时调用 layoutAttributesForItemAtIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18989069/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com