【发布时间】:2015-06-12 16:52:13
【问题描述】:
我正在使用最新稳定的 Swift 在我的函数中,我得到 致命错误。当我运行我的 ios 应用程序时。
"致命错误:在展开 Optional 时意外发现 nil 价值”。
我搜索了答案,但他们提供了不同的解包方法。
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! UICollectionViewCell
var imageView = cell.viewWithTag(1) as! UIImageView
imageView.image = UIImage(named: imagesArray[indexPath.row])
}
【问题讨论】: