这是我的ImageController类(一个ViewController) 仅显示集合视图的背景,而其中的单元格不显示。有帮助吗?有没有我没有正确初始化的东西?
这是班级:
class ImageController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
let reuseIdentifier = "imageCell"
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! ImageCell
cell.myImage.image = unknown //name of image, isn't the cause of error
return cell
}
}