我正在設置一個顯示圖像的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! –