我正在设置一个显示图像的UICollectionView
的新项目。我创建了ViewController
和CellViewController
,就像它应该的那样。'UICollectionViewCell'类型的值没有成员'imageView'
在CellViewController
的代码如下:
import UIKit
class ClubCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!
}
但在ViewController
当我设置它给我的错误形象。下面的代码:
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier,
for: indexPath)
// Configure the cell
cell.backgroundColor = UIColor.black
cell.imageView.image = UIImage(named: "pic1")
return cell;
}
在此先感谢..
你得到的错误是什么?你把你的'@ IBOutlet'连接到你的'.xib'文件了吗? – dirtydanee
我得到的错误是'UICollectionViewCell'类型的值没有成员'imageView'尽管我已将单元格连接到我的故事板上的新类ClubCollectionViewCell! –