मैं सिर्फ पहली बार के लिए UICollectionView के साथ प्रयोग करना शुरू कर दिया है। अच्छी तरह से काम करने लगता है, लेकिन इसके बारे में एक मुद्दा और एक सवाल है।UICollectionView registerCell - खाली कोशिकाओं
मैं नीचे के रूप में मेरी UICollectionView सेटअप है और आप कस्टम सेल के साथ:
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section
{
return 10;
}
- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView
{
return 1;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
ContactCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
cell.nameLbl.text = @"text";
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(145, 95);
}
- (UIEdgeInsets)collectionView:
(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(10, 10, 10, 10);
}
तो यह है सब dandy, इस लाइन तथापि मैं जोड़ लिया है viewDidLoad
रहे हैं:
[collectionView registerClass:[ContactCell class] forCellWithReuseIdentifier:@"Cell"];
इस के कारण परेशानी है और मुझे समझ में नहीं आता क्यों। जब मैं इस लाइन को सक्षम करता हूं, तो मेरी सभी कोशिकाएं खाली होती हैं। कैसे? मैं क्या खो रहा हूँ?
इसके अलावा, के रूप में मैं इसे समझ, अगर है कि रेखा पुन: प्रयोज्य कोशिकाओं में सक्षम बनाता है, कारण है कि मैं करने के लिए एक संग्रह को देखने के लिए एक तालिका दृश्य में करने के लिए नहीं होने बनाम साथ है?
किसी भी तकनीकी या व्याख्यात्मक मदद की सराहना की, धन्यवाद।
कैसे आप को सेल के लिए दृश्य की स्थापना कर रहे हैं? प्रोग्रामिंग में अपने उपclass में? – jackslash
मैंने इसे अपने स्टोरीबोर्ड में स्थापित किया है। मेरे पास एक एकल सेल के साथ एक UICollectionView है, उस सेल में इसकी पहचानकर्ता, कस्टम क्लास हुक अप और लेबल है। –