【发布时间】:2015-06-20 18:46:41
【问题描述】:
我有一个UICollectionView,为此我实现了UICollectionViewFlowLayout 的自定义子类并实现了layoutAttributesForElementsInRect 方法。我的视图是可滚动的,并且我实现了shouldInvalidateLayoutForBoundsChange 方法来返回YES。所以每次我滚动时,layoutAttributesForElementsInRect 都会被调用。
但是当我在视图的上半部分滚动时,它被调用的矩形是整个集合的矩形(例如{{0, 0}, {320, 1136}} {{0, 567}, {320, 548}}),当我滚动到一半时,矩形变成了底部一半(即{{0, 568}, {320, 568}} {{0, 568}, {320, 548}})。这完全打破了我的布局。我需要 layoutAttributesForElementsInRect 总是被整个视图的矩形调用。
为什么它使用另一个矩形,以及如何关闭更改矩形的行为?
【问题讨论】:
标签: ios objective-c