【发布时间】:2017-11-01 20:30:04
【问题描述】:
我正在故事板中加载collectionview。但是当我运行它时,它没有出现。就在那时,我发现委托和数据源没有设置。但是当我设置委托和数据源并再次运行时,程序崩溃说'could not dequeue a view of kind: UICollectionElementKindCell with identifier prdImgscellIdentifier - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
似乎我没有错过任何东西..但无法弄清楚为什么会发生崩溃..
这是我的cellForItemAt...
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! productImagesCollectionViewCell
cell.myImageView.image = UIImage(named: "appLogo.jpg")
return cell
}
【问题讨论】:
-
您使用的是自定义单元格还是自定义标题?
-
我想我正在使用自定义单元格......顺便说一句,自定义标题是什么......?
-
确保单元格标识符不会出现拼写错误。
标签: ios swift uicollectionview