[英]Custom UITableCell has nil outlets
我有一個表格視圖,我需要使用帶有標簽和文本字段的自定義單元格。 我已經在情節提要中設計了單元格。 我已將自定義單元格的類設置為ItemRowCell
並ItemRowCell
指定了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.