【问题标题】:Inconsistent loading of Glance in Watch OS 2Watch OS 2 中 Glance 的加载不一致
【发布时间】:2015-12-29 18:57:34
【问题描述】:

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

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

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

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

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

【问题讨论】:

    标签: ios swift watchkit apple-watch watchos-2


    【解决方案1】:

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

    示例代码sn-p

    [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];
    });
    

    【讨论】:

    • 谢谢!我在另一个应用程序中做了类似的事情,但我找不到它,你能在你的答案中添加 GCD 的实现吗?
    猜你喜欢
    • 2016-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-14
    • 1970-01-01
    • 1970-01-01
    • 2015-11-14
    • 1970-01-01
    相关资源
    最近更新 更多