soe*_*606 5 casting uicollectionview swift
我正在制作一个集合视图,并制作了我自己的自定义collectionCell.我已在身份检查员中指明了这一点,据我所知,我做的一切都是正确的.
代码是
import UIKit
class SubjectCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var label: UILabel!
}
Run Code Online (Sandbox Code Playgroud)
并在我的collectionViewController中
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! SubjectCollectionViewCell
return cell
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息
"无法将'UICollectionViewCell'类型的值(0x110460820)转换为'project.SubjectCollectionViewCell'(0x10eceeda0).(lldb)"
小智 12
参考:无法转换'UICollectionViewCell'类型的值
如果你在collectionViewController中看到这个,删除它.
self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)
| 归档时间: |
|
| 查看次数: |
3956 次 |
| 最近记录: |