2015-05-23 8 views
5

मेरे पास एक स्टोरीबोर्ड में एक यूआईसीओलेक्शन व्यू कंट्रोलर है जिसे XCollectionViewController.swift नामक फ़ाइल से जोड़ा गया है जो UICollectionViewController का उप-वर्ग है।सेल UICollectionView में नहीं दिख रहे हैं?

super.viewDidLoad() 
    // Register cell classes 
    self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) 
} 


    override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { 
    //#warning Incomplete method implementation -- Return the number of sections 
    return 4 
} 


override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 
    //#warning Incomplete method implementation -- Return the number of items in the section 
    return 10 
} 

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! UICollectionViewCell 

    // Configure the cell 

    return cell 
} 

मैं सेल के रूप में यह फाइल में नामित किया गया है सेट के लिए पुन: उपयोग पहचानकर्ता:

मेरे कोड इस प्रकार है।

रन पर मैं संग्रह दृश्य की पृष्ठभूमि देख सकता हूं, लेकिन 40 सेल जो मुझे देखना चाहिए। गलत क्या है?

उत्तर

7

बस इस लाइन को viewDidLoad विधि में हटाएं, आपकी 40 कोशिकाओं को दिखाएगी।

self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) 
+1

क्यों? और यदि मैंने किसी को परिभाषित नहीं किया है तो मैं पुन: उपयोग पहचानकर्ता का संदर्भ कैसे ले सकता हूं? –

+0

@ लुकासकिलिंस्की आप अपने स्टोरीबोर्ड में पुन: उपयोग पहचानकर्ता सेट कर सकते हैं। – tounaobun

+0

उत्तर देने के लिए धन्यवाद। मुझे अभी एहसास हुआ कि मैंने आपके जवाब का गलत व्याख्या किया है। माफ़ कीजिये! –

संबंधित मुद्दे