Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Tableview中的Swift3.0自定义行返回零_Ios_Swift_Uitableview_Swift3 - Fatal编程技术网

Ios Tableview中的Swift3.0自定义行返回零

Ios Tableview中的Swift3.0自定义行返回零,ios,swift,uitableview,swift3,Ios,Swift,Uitableview,Swift3,我一直在遵循苹果在开发者页面上的指导 文件TableViewController中的以下代码块给我带来了一些麻烦 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cellIdentifier = "CoinTableViewCell" guard let cell =

我一直在遵循苹果在开发者页面上的指导

文件TableViewController中的以下代码块给我带来了一些麻烦

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cellIdentifier = "CoinTableViewCell"
    
    guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? CoinsTableViewCell  else {
        fatalError("The dequeued cell is not an instance of MealTableViewCell.")
    }
    
    let coinrow = coins[indexPath.row]
    

    cell.rowLabel.text = coinrow.name // error on this line
    

    return cell
}
我得到一个运行时错误,发生在最后一行代码的第二行,声明

fatal error: unexpectedly found nil while unwrapping an Optional value (lldb) 
我使用断点发现
cell.rowLabel
的值为零。但是我不知道为什么。自定义行的标识符为“CoinTableViewCell”。你知道怎么回事吗


您连接了rowLabel的插座了吗?是的,我连接了,在单元格的自定义控制器内,您正在将单元格转换为键入
CoinsTableViewCell
。然而,在fatalError语句中,您将其称为
MealTableViewCell
。可能是
rowLabel
是在
MealTableViewCell
中定义的,而不是
CoinTableViewCell
。忘记更改Apple示例代码中的文本-不过这只是一条字符串错误消息,MealTableViewCell在我的项目中不存在。不过接得不错!您尚未将
rowLabel
插座连接到故事板单元格中的
UILabel
插座。是否已连接rowLabel插座?是的,我已连接,在您正在将单元格强制转换为键入
CoinsTableViewCell
的单元格的自定义控制器内。然而,在fatalError语句中,您将其称为
MealTableViewCell
。可能是
rowLabel
是在
MealTableViewCell
中定义的,而不是
CoinTableViewCell
。忘记更改Apple示例代码中的文本-不过这只是一条字符串错误消息,MealTableViewCell在我的项目中不存在。不过接得不错!您尚未将
rowLabel
插座连接到情节提要单元中的
UILabel