ios - 在 Watch OS 2 中加载 Glance 不一致

标签 ios swift watchkit apple-watch watchos-2

我的 Watch OS2 应用一目了然,顶部组是静态标签,底部组是通过调用 HealthKit(锻炼)填充的 WKInterfaceTable。我还有一个图像作为底部组的背景。

应用程序的主要部分具有加载到 WKInterfaceTable 中的相同数据。

我正在 Apple Watch 和 iPhone 5s 上进行测试。

应用程序本身运行良好,加载数据完全没有延迟。

然而,10 次中有 9 次只加载顶部静态标签而不加载底部组(甚至不加载背景图像)?每隔一段时间它就会正确加载。我已经卸载并重新安装,但我无法弄清楚。一瞥是否与网络连接质量有关?我很难过。

最佳答案

我在 Watch OS 1 上遇到了一个非常相似的问题,我的标签没有正确更新。我首先将标签设置为空字符串,然后将其设置为一些动态文本。在某些情况下,某些标签没有将标签设置为空字符串。 像你一样,它发生了 10 次中的 9 次。 我尝试将所有与 UI 相关的东西放在调度主线程中,但它仍然有那个问题。 最后,我通过首先将标签设置为空字符串来解决它。然后,在 0.1 秒后执行调度以将标签设置为动态文本。

示例代码片段

[self.label1 setText:@""];
[self.label2 setText:@""];
[self.label3 setText:@""];
[self.label4 setText:@""];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    SampleViewModel *model = [accounts firstObject];
    if (model.currentText) {
        [self.label2 setText:[model formattedText]];
    } else {
        [self.label2 setText:@"Currently unavailable"];
        [self.label2 setTextColor:[UIColor lightGrayColor]];
    }

    [self.label3 setText:[model formattedText]];

    [self.label4 setText:model.accountNickname];
});

关于ios - 在 Watch OS 2 中加载 Glance 不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32892362/

相关文章:

ios - WebView 从照片库中选择文件

ios - 更新表格 View 内容框架原点

ios - App 与 iWatch 通信 : is using app group the only way?

ios - 如何通过 Google Cloud Messaging 向 iOS 发送静默推送

ios - swift : "unexpectedly found nil while unwrapping an Optional value"

ios - 查询 1 :1 private rooms efficiently with Firebase

ios - 状态栏在 iOS 6 上消失了

ios - WkWebView 不全屏旋转视频?

watchkit - 在 WatchKit 中重新加载表

swift - watch 屏幕关闭时,Complication 能否访问 Healthkit?