我已将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:
来做到这一点。我究竟做错了什么? (这些单元格在数据源中被要求)