【发布时间】:2015-11-01 14:35:00
【问题描述】:
我正在尝试将值从 UiCollectionViewController 传递到 UICollectionViewCell。
我创建了一个自定义的UICollectionViewCell,连接到我的故事板中的 CellView。然后我创建了一个 UILabel IBOutlet。
当我尝试向我的 UICollectionViewCell 类发送值时,我总是收到错误消息:
fatal error: unexpectedly found nil while unwrapping an Optional value
这是来自线路:
videoCell.nameUsrVideo.text = "TEST"
我也看不到单元格中的任何物体
知道为什么吗?
UiCollectionViewController:
override func viewDidLoad() {
super.viewDidLoad()
collectionView!.registerClass(videoCellClass.self, forCellWithReuseIdentifier: "VideoCell")
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let videoCell = collectionView.dequeueReusableCellWithReuseIdentifier("VideoCell", forIndexPath: indexPath) as! videoCellClass
videoCell.nameUsrVideo.text = "TEST"
return videoCell
}
UICollectionViewCell:
class videoCellClass: UICollectionViewCell {
@IBOutlet weak var nameUsrVideo: UILabel!
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
【问题讨论】:
标签: ios swift uicollectionviewcell