我已经修改为RFQuiltLayout
可以使用标题视图。在layoutAttributesForElementsInRect:(CGRect)rect
我添加属性
UICollectionViewLayoutAttributes* att = [self layoutAttributesForDecorationViewOfKind:RFQuiltHeader atIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
[attributes addObject:att];
这是返回布局属性的方法:
- (UICollectionViewLayoutAttributes *)layoutAttributesForDecorationViewOfKind:
(NSString*)decorationViewKind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewLayoutAttributes *layoutAttributes = [UICollectionViewLayoutAttributes layoutAttributesForDecorationViewOfKind:decorationViewKind withIndexPath:indexPath];
layoutAttributes.frame = CGRectMake(0.0, 0.0, self.collectionView.contentSize.width, 100);
layoutAttributes.zIndex = -1;
return layoutAttributes;
}
我在初始化中注册它
[self registerClass:[EditionGridHeaderView class] forDecorationViewOfKind:RFQuiltHeader];
headerview 加载正常,但从不要求数据源,所以我不能修改它的内容。我当然可以破解它以获得指向 headerview 的指针,但
collectionView:viewForSupplementaryElementOfKind:atIndexPath:
应该调用它来正确执行此操作。我究竟做错了什么?(应在数据源中要求单元格)