नहीं दिखा रहा है मैं एक ऐसे प्रोजेक्ट पर काम कर रहा हूं जो कई एल्बम दिखाने के लिए UICollectionView
का उपयोग करता है। आइटम ठीक दिखाते हैं, लेकिन अब मैं पहले खंड के ऊपर एक शीर्षलेख दिखाना चाहता हूं।UICollectionView शीर्षलेख
ऐसा करने के लिए, मैंने अपनी init विधि में registerNib:forSupplementaryViewOfKind:withReuseIdentifier:
जोड़ा। इस तरह:
[self.collectionView registerNib:[UINib nibWithNibName:@"AlbumHeader" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kAlbumHeaderIdentifier];
(। AlbumHeader
नोक वर्ग AlbumHeader
, जो UICollectionView
का एक उपवर्ग है के एक दृश्य शामिल हैं)
उसके बाद, मैं कार्यान्वित collectionView:viewForSupplementaryElementOfKind:atIndexPath
विधि:
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
return [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kAlbumHeaderIdentifier forIndexPath:indexPath];
}
अब मुझे लगता है कि हेडर व्यू लोड करने का प्रयास करना चाहिए। लेकिन ऐसा नहीं है, पूरक दृश्य के लिए विधि को बुलाया नहीं जाता है।
मुझे क्या याद आ रही है? घंटों तक अटक गया, UICollectionView
पर कई बार प्रलेखन पढ़ा है, लेकिन कुछ भी मदद नहीं करता है। कोई विचार? बस एक बात काम करने के लिए
- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
को लागू करने के तरीकों में से एक टन नहीं है ... मैं भी सीख रहा हूँ:
किसी को भी इस मुद्दे को चलाने के लिए, इस काम को करने के लिए, मुझे 'collectionview.footerReferenceSize' का आकार भी देना पड़ा। यकीन नहीं है कि अगर रिक आईओएस 7 विशिष्ट है ... –
यह एक अविश्वसनीय टिप है। धन्यवाद एक लाख, Guido! – Fattie
उस बक्षीस का आनंद लें! :) – Fattie