Nagłówek UICollectionView nie jest wyświetlany

Pracuję nad projektem, który używaUICollectionView aby pokazać kilka albumów. Elementy są w porządku, ale teraz chcę pokazać nagłówek nad pierwszą sekcją.

Aby to zrobić, dodałemregisterNib:forSupplementaryViewOfKind:withReuseIdentifier: do mojej metody inicjowania. Lubię to:

[self.collectionView registerNib:[UINib nibWithNibName:@"AlbumHeader" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kAlbumHeaderIdentifier];

(TheAlbumHeader Stalówka zawiera widok klasyAlbumHeader, która jest podklasąUICollectionView.)

Potem zaimplementowałemcollectionView:viewForSupplementaryElementOfKind:atIndexPath metoda:

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    return [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kAlbumHeaderIdentifier forIndexPath:indexPath];
}

Teraz powinien spróbować załadować widok nagłówka, jak sądzę. Ale tak nie jest, metoda widoku dodatkowego nie jest wywoływana.

czego mi brakuje? Utknąłem na wiele godzin, zapoznałem się z dokumentacjąUICollectionViews wiele razy, ale nic nie pomaga. jakieś pomysły?

questionAnswers(3)

yourAnswerToTheQuestion