는 프로그래밍 방식으로 (그리고 다른 XIB 파일에 HeaderReusableView 유지) : 다음
[self.collectionView registerNib:[UINib nibWithNibName:@"ItemHeaderView" bundle:nil]
forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:kItemSectionHeaderViewID];
:
- (CGSize) collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
referenceSizeForHeaderInSection:(NSInteger)section {
return CGSizeMake(60.0f, 30.0f);// width is ignored
}
물론 :
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
viewForSupplementaryElementOfKind:(NSString *)kind
atIndexPath:(NSIndexPath *)indexPath {
NSString *productId = nil; ///
ItemHeaderView *view = nil;
view = [collectionView dequeueReusableSupplementaryViewOfKind:kind
withReuseIdentifier:kItemSectionHeaderViewID
forIndexPath:indexPath];
view.titleLabel.text = productId;
view.backgroundColor = [UIColor yellowColor];
return view;
}
I을 xib을 사용하고있었습니다. 당신 솔루션이 나를 위해 일했습니다. [' 내가 '[self.selectionCollectionView registerNib로 변경보다, 처음에 나는'[: [UINib nibWithNibName : 전무] forCellWithReuseIdentifier "HeaderView"@ "FlootThumbnailCollectionReusableView"번들 @ self.selectionCollectionView registerNib] 저항의 NIB을 시도하고 있었다 UINib nibWithNibName : @ "FlootThumbnailCollectionReusableView"번들 : nil] forCellWithReuseIdentifier : @ "HeaderView"]' –