【发布时间】:2013-05-10 21:24:42
【问题描述】:
我正在尝试在我的 UICollectionView 标头中使用自定义 UICollectionReusableView(具有自己的类和 XIB)。但是在标题的位置获取数据后,我什么都没有。
我的步骤:
-
在viewDidLoad中注册类:
[self.collectionView registerClass:[CollectionViewHeader class] forSupplementaryViewOfKind: UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"]; -
试图显示:
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { UICollectionReusableView *reusableView = nil; if (kind == UICollectionElementKindSectionHeader) { CollectionViewHeader *collectionHeader = [self.collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath]; NSInteger section = [indexPath section]; id <NSFetchedResultsSectionInfo> sectionInfo = [fetchRecipes sections][section]; collectionHeader.headerLabel.text = @"bla-bla-bla"; reusableView = collectionHeader; } return reusableView; }
谁能告诉我怎么了? ) 感谢您的任何建议
【问题讨论】:
标签: ios xib uicollectionview uicollectionreusableview