I have custom UICollectionReusableView (with nib). As a result, I need to register nib.
- (void)setUpInterface {
CGRect screenBounds = [UIScreen mainScreen].bounds;
[self.view setW:CGRectGetWidth(screenBounds)];
[self.cvMain registerNib:[UINib nibWithNibName:@"FlightDetailCollectionView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:COLLECTION_VIEW_HEADER];
}
#pragma mark - UICollectionViewDelegate
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
if (kind == UICollectionElementKindSectionHeader) {
FlightDetailCollectionView *headerView = (FlightDetailCollectionView *)[collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:COLLECTION_VIEW_HEADER forIndexPath:indexPath];
// [headerView setData:self.flightData];
return headerView;
}
UICollectionReusableView *reusableview = nil;
return reusableview;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
return CGSizeMake(CGRectGetWidth(self.cvMain.frame), 220);
}
I believe I am doing correctly and it indeed show my custom view. The only problem is that dequeueReusableSupplementaryViewOfKind give me UICollectionReusableView class and it is not my custom class. As a result, I can't even pass data to my view. How shall I do?