0

我想将默认页眉设置为UICollectionView。我使用下面的代码,它崩溃了。如何将页眉设置为UICollectionView

-viewDidLoad

[feedcollectionview registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"cell"]; 

-viewForSupplementaryElementOfKind

UICollectionReusableView *reusableview = nil; 
    if (kind == UICollectionElementKindSectionHeader) { 
     UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath]; 
     [headerView setBackgroundColor:[UIColor redColor]];   
     reusableview=headerView; 

谢谢

在viewDidLoad中标识

回答

0

不相同viewForSupplementaryElementOfKind 你必须选择@ “细胞” 或@ “HeaderView”