UICollectionView
を使用して複数のアルバムを表示するプロジェクトに取り組んでいます。アイテムは問題なく表示されますが、最初のセクションの上にヘッダーを表示したいと思います。
これを行うためregisterNib:forSupplementaryViewOfKind:withReuseIdentifier:
に、 init メソッドに を追加しました。このような:
[self.collectionView registerNib:[UINib nibWithNibName:@"AlbumHeader" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kAlbumHeaderIdentifier];
( AlbumHeader
Nib にAlbumHeader
は、 のサブクラスであるクラス のビューが含まれていますUICollectionView
。)
その後、collectionView:viewForSupplementaryElementOfKind:atIndexPath
メソッドを実装しました:
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
return [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kAlbumHeaderIdentifier forIndexPath:indexPath];
}
これで、ヘッダー ビューを読み込もうとするはずです。しかし、そうではありません。補足ビューのメソッドは呼び出されません。
私は何が欠けていますか?何時間も立ち往生し、s のドキュメントをUICollectionView
何度も読みましたが、何も役に立たないようです。何かご意見は?