簡體   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