WKInterfaceTable没有加载值

问题描述 投票:0回答:1

我正在从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()
        }
    }

该问题有解决方法吗?建议非常感谢。

swift watchkit apple-watch watch-os
1个回答
0
投票

在interfaceController的Identity检查器中

它是

enter image description here

当我改变如下所示的相同时,它通过苹果魔法工作。 enter image description here

不知道这个修复工作原理背后的原因。希望将来有人可以帮助这个答案。

© www.soinside.com 2019 - 2024. All rights reserved.