相关疑难解决方法(0)

致命错误:在解包可选值时意外发现nil

UICollectionView在Swift 中使用了一个,但是当我尝试更改单元格标签的文本时,我得到了.

    func collectionView(collectionView: UICollectionView!, numberOfItemsInSection section: Int) -> Int
{
    return 5
}

func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell!
{
    var cell = collectionView.dequeueReusableCellWithReuseIdentifier("title", forIndexPath: indexPath) as TitleCollectionViewCell
    // Next line: fatal error: unexpectedly found nil while unwrapping an Optional value
    cell.labelTitle.text = "This is a title"
    return cell
}
Run Code Online (Sandbox Code Playgroud)

有谁知道这个?

控制台上警告的屏幕截图

ios uicollectionview swift

125
推荐指数
6
解决办法
25万
查看次数

标签 统计

ios ×1

swift ×1

uicollectionview ×1