swift - WKInterfaceTable 未加载值
问题描述
我正在从 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()
}
}
这个问题有什么解决方法吗?建议非常受欢迎。