我正在为UICollectionView编写自定义流布局.
我可以看到并滚动细胞.
我可以看到并滚动细胞.
所以,
- (UICollectionViewLayoutAttributes *) layoutAttributesForSupplementaryViewOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
永远不会被召唤.
在数据源中这种方法:
- (UICollectionReusableView *) collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
也永远不会被召唤.
编辑:
这是layoutAttributesForElementsInRect:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { NSMutableArray * attributes = [NSMutableArray arrayWithCapacity:[[self.layoutInfo allKeys] count]]; for(NSIndexPath * indexPath in self.layoutInfo) { UICollectionViewLayoutAttributes *itemAttributes = [self.layoutInfo objectForKey:indexPath]; if(CGRectIntersectsRect(rect,itemAttributes.frame)) { [attributes addObject:itemAttributes]; } } return attributes; }
解决方法
您需要实现
layoutAttributesForElementsInRect:
以返回每个补充视图的属性实例(除了每个单元格):
Subclasses must override this method and use it to return layout information for all items whose view intersects the specified rectangle. Your implementation should return attributes for all visual elements,including cells,supplementary views,and decoration views.