UICollectionView UIImageView图像没有出现

时间:2014-12-16 10:43:20

标签: ios swift uiimageview uicollectionview

我无法让某些图片出现在UICollectionView中。 我可以看到正在创建单元格,如果我通过故事板手动设置图像,则会显示图像,但我无法在代码中实现它

集合视图使用自定义单元格,位于

之下
class CardsListCell: UICollectionViewCell {
    @IBOutlet weak var image: UIImageView!

    override func awakeFromNib() {
        super.awakeFromNib()
    }

}]

图像在故事板中连接,单元格具有正确的类集

显示图像的代码

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> CardsListCell {
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as CardsListCell

        // Configure the cell

        var card : Card = self.fetchedResultsController.objectAtIndexPath(indexPath) as Card

        var img = UIImage(named: card.image)
        var imageView = UIImageView(image: img)

        cell.image = imageView


        return cell
    }

看起来正在创建图像和图像视图,因为我可以将它们打印出来

0 个答案:

没有答案
相关问题