首页 > 解决方案 > 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()
        }
    }

这个问题有什么解决方法吗?建议非常受欢迎。

标签: swiftwatchkitapple-watchwatchos

解决方案


在 interfaceController 的身份检查器中

它是

在此处输入图像描述

当我改变如下所示的相同时,它由 apple magic 工作在此处输入图像描述

不知道此修复程序如何工作的原因。希望将来有人可以帮助回答这个问题。


推荐阅读