“CollectionViewCell”类型的值没有成员“imageView”

时间:2016-02-06 04:24:54

标签: xcode swift

由于以下两个错误,我的构建失败

  1. 类型ExploreCollectionViewCell的值没有成员'imageView'
  2. 类型ExploreCollectionViewCell的值没有成员'titleLabel'
  3. 我无法弄清楚导致失败的变化或如何在不重做整个项目的情况下修复它。

    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    
        let cellApt = collectionView.dequeueReusableCellWithReuseIdentifier("cellApt", forIndexPath: indexPath) as! ExploreCollectionViewCell
    
        cellApt.imageView?.image = self.imageArray[indexPath.row]
        cellApt.titleLabel?.text = self.condoCells[indexPath.row]
        cellApt.setNeedsLayout()
    
        return cellApt
    }
    

    storyboard

2 个答案:

答案 0 :(得分:0)

替换:

let cellApt = collectionView.dequeueReusableCellWithReuseIdentifier("cellApt", forIndexPath: indexPath) as! ExploreCollectionViewCell

使用:

let cellApt: ExploreCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("cellApt", forIndexPath: indexPath) as! ExploreCollectionViewCell

答案 1 :(得分:0)

ExploreCollectionViewCell应具有以下代码之类的属性:

class ExploreCollectionViewCell: UICollectionViewCell {
    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var titleLabel: UILabel!

    ...
}