【发布时间】:2015-04-19 13:45:09
【问题描述】:
假设我有一个包含部分和项目的 UICollectionview。 对于每个部分,我都会生成一个标题,如下所示。
问题:如何将顶部标题视图添加到 collectionView 本身 这与下面演示的部分标题不同(使用objective-c、IB、Auto Layouts)
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionReusableView *reusableview = nil;
if (kind == UICollectionElementKindSectionHeader) {
HeaderCollectionReusableView *headerView = [self.collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header" forIndexPath:indexPath];
headerView.label1.text = "This is a section title";
reusableview = headerView;
}
return reusableview;
}
【问题讨论】:
-
在高度 = 0 的集合视图上方创建一个视图并使用自动布局以编程方式更改它,您可以选择吗?
-
是的,如果您愿意,请发布详细的答案。
标签: ios objective-c uicollectionview