我有一个UICollectionView
我已经实现了一个自定义子类UICollectionViewFlowLayout
并实现layoutAttributesForElementsInRect
方法。我的视图是可滚动的,我已经实现了shouldInvalidateLayoutForBoundsChange
方法返回YES。所以每次我滚动,layoutAttributesForElementsInRect
被调用。rect来自layoutAttributesForElementsInRect的哪里?
但是当我在上半部分的视图中滚动时,它被调用的矩形是整个集合的矩形(例如{{0, 0}, {320, 1136}} {{0, 567}, {320, 548}}
),当我滚动过去一半时矩形变成只有下半部分(即{{0, 568}, {320, 568}} {{0, 568}, {320, 548}}
)。这完全打破了我的布局。我需要layoutAttributesForElementsInRect始终用整个视图的rect调用。
为什么它会使用其他矩形,我如何关闭矩形变换行为?