0

I want to set the default section header to the UICollectionView.I used the below code,it crashed.

In -viewDidLoad

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

In -viewForSupplementaryElementOfKind

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

Thank you

0yeoj
  • 4,500
  • 3
  • 23
  • 41
ajay
  • 21
  • 2

1 Answers1

0

in ViewDidLoad Identifier not same viewForSupplementaryElementOfKind you must choose @"cell" or @"HeaderView"

Tanakorn.K
  • 150
  • 9