Mat*_*oal 3 ios uicollectionview
我已经创建了我的自定义布局子类UICollectionViewLayout
。它完全按照我的需要工作,但是当集合只有少量元素(如“3”)时,该方法会layoutAttributesForElementsInRect
询问带有0 width
.
这是我的 layoutAttributesForElementsInRect 实现的代码:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect{
NSMutableArray *results = [NSMutableArray array];
for (UICollectionViewLayoutAttributes *attributes in self.elementsAttributes) {
if(CGRectIntersectsRect(rect, attributes.frame)){
[results addObject:attributes];
}
}
return results;
}
Run Code Online (Sandbox Code Playgroud)
我在prepareLayout
方法中缓存了属性......所以例如我有 3 个元素,但是rect
我从前一个函数收到的参数只是“不可能”,确实是:{{0, 0}, {0, 180}}
.
仅当我的集合视图中有几个单元格时才会发生这种情况。
为什么以及如何获取应显示的所有单元格的属性?
归档时间: |
|
查看次数: |
1449 次 |
最近记录: |