2014-11-13 3 views
-1

Я пытаюсь реализовать контроллер просмотра коллекции. Однако по какой-то случайной причине каждый раз, когда я запускаю iOS-симулятор, изображения не появляются ... Кроме того, компилятор не бросает мне никаких ошибок ... Итак, я не знаю, чего я здесь не вижу ...Ошибка логики CollectionViewController?

CollectionView контроллер

import UIKit 

let reuseIdentifier = "Cell" 

class CollectionViewController: UICollectionViewController { 

    var imagesCell : [String] = [] 

    @IBOutlet var collectionSaso: UICollectionView! 

    override func viewDidLoad() { 
     super.viewDidLoad() 

    // Register cell classes 
    self.collectionView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) 

    // Do any additional setup after loading the view. 
    imagesCell = ["miEsposa.jpg", "miEsposa.jpg", "miEsposa.jpg"] 
} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
    // Dispose of any resources that can be recreated. 
} 

// MARK: UICollectionViewDataSource 

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


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

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 

    let cell = collectionSaso.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as CollectionViewCell 

    // Configure the cell 
    cell.imageHolder.image = UIImage(named: imagesCell[indexPath.item]) 
    return cell 
} 

CollectionViewCell

import UIKit 

class CollectionViewCell: UICollectionViewCell { 

    @IBOutlet weak var imageHolder: UIImageView! 
} 

enter image description here

enter image description here

+0

Вы не видите предупреждение, которое Apple предоставила в методе numberOfSectionsInCollectionView? Вы не должны игнорировать предупреждения. – rdelmar

ответ

2

Вам необходимо указать 1 для количества разделов.

Смежные вопросы