繁体   English   中英

自定义UITableCell有零个出口

[英]Custom UITableCell has nil outlets

我有一个表格视图,我需要使用带有标签和文本字段的自定义单元格。 我已经在情节提要中设计了单元格。 我已将自定义单元格的类设置为ItemRowCellItemRowCell指定了itemRowCell的重用标识符。 我已经将标签和文本字段连接到ItemRowCell的相应插座。

这是我的ItemRowCell类的代码

class ItemRowCell: UITableViewCell {
@IBOutlet weak var itemDescription: UILabel!
@IBOutlet weak var quantity: UITextField!

override func awakeFromNib() {
    super.awakeFromNib()
    // Initialization code
}

override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)

    // Configure the view for the selected state
}

}

在我的数据源中,我有此代码

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "itemRowCell", for: indexPath) as! ItemRowCell
    let (description, quantity) = self.currentItems[indexPath.row]

    cell.itemDescription.text = description
    cell.quantity.text = String(quantity)

    return cell
}

不幸的是,单元中的两个出口都为零。

断开并重新连接插座可解决此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM