我正在製作一個集合視圖,並且創建了自己的自定義collectionCell。我在身份檢查員中已經說明了這一點,並且據我所知,我做的一切都是正確的。爲什麼我不能向下轉發UICollectionViewCell到它的子類?
的代碼是
import UIKit
class SubjectCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var label: UILabel!
}
,並在我的collectionViewController
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! SubjectCollectionViewCell
return cell
}
我收到以下錯誤消息
「無法投類型的值 'UICollectionViewCell'(0x110460820)爲' project.SubjectCollectionViewCell'(0x10eceeda0)。 (lldb)「
你確定這是自動的Xcode在viewDidLoad中(產生的線正在出隊正確的細胞?確保重用標識符正確,並且還要在界面構建器中設置自定義單元類。 – almas