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」