0

デフォルトのセクション ヘッダーを に設定したいのですが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;

ありがとうございました

4

1 に答える 1

0

ViewDidLoad Identifier が同じではない viewForSupplementaryElementOfKind では、@"cell" または @"HeaderView" を選択する必要があります

于 2016-02-26T06:09:00.127 に答える