我正在从iOS应用程序的上下文中加载接口表的值。数据传递成功,但tableview方法
rowController(at: index)返回nil值,并且在代码行之后numberOfRows变量仍为0
tableView.setNumberOfRows(3, withRowType: "deviceRow")我的整体代码是
func setupTable() {
tableView.setNumberOfRows(devicesArray.count, withRowType: "deviceRow2")
for (index, device) in self.devicesArray.enumerated() {
if let row = tableView.rowController(at: index) as? MeasurementCell {
row.deviceNameLabel.setText(device)
row.readingLabel.setText(self.readingsArray[index])
let statusColor = colorWithHexString(hex: self.colorsArray[index])
// row.backgroundGroupView.setBackgroundColor(statusColor.withAlphaComponent(0.2))
row.readingLabel.setTextColor(statusColor)
row.dateLabel.setText(self.datesArray[index])
row.readingLabel.setTextColor(self.getColor(fromString: self.colorsArray[index]))
row.readingLabel.sizeToFitWidth()
}
}是否有解决此问题的方法?建议被高度评价。
发布于 2018-09-12 11:32:49
在interfaceController的身份检查器中
确实是

当我按如下所示进行更改时,苹果魔术起作用了。

不知道这个修复是如何工作的。希望将来的任何人都能帮助回答这个问题。
https://stackoverflow.com/questions/52272519
复制相似问题