2017-04-06 74 views
0

我有一个表格视图,我需要使用带有标签和文本字段的自定义单元格。我设计了故事板中的单元格。我已将自定义单元格的类设置为ItemRowCell,并且我已给它一个重用标识符itemRowCell。我已将标签和文本字段连接到ItemRowCell的相应网点。自定义UITableCell没有插座

这是我的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 
} 

不幸的是,在小区两个出口都是零。

+2

单元格是否在单独的'xib'文件中设计?或者您是否将它作为原型单元格添加到'UITableViewController'中? – Losiowaty

+0

您可以附加原型单元格的屏幕截图,并确保它们与ItemRowCell类连接良好。 –

+0

尝试重新连接插座 – Anuraj

回答

0

断开连接并重新连接网点解决了问题。