gpt4 book ai didi

ios - 在 iPhone 和 Apple Watch 之间发送数据时减少延迟的策略?

转载 作者:行者123 更新时间:2023-11-29 12:22:48 26 4
gpt4 key购买 nike

我可以使用什么策略来减少在 iPhone 和 Apple Watch 之间发送数据时的延迟?

在模拟器上,有时滞后通常 >0.1s,这意味着计数器(参见下面的代码)通常会跳过一些数字。运行计数器几秒钟后,延迟增加到 >1s,并且计数器非常频繁地跳过 10+ 个数字。

我正在尝试为 Apple Watch 构建一个类似于 spritz 的应用程序,它需要单词以每分钟约 500 个单词或每 0.12 秒 1 个单词的速度在屏幕上闪烁。

- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
self.number = 0;
NSTimer *t = [NSTimer timerWithTimeInterval:0.1 target:self selector:@selector(updateLabelText) userInfo:nil repeats:YES];
NSRunLoop *runner = [NSRunLoop currentRunLoop];
[runner addTimer:t forMode: NSDefaultRunLoopMode];
}
- (void)updateLabelText {
NSString *str = [NSString stringWithFormat:@"number %ld", self.number];
[self.testLabel setText:str];
self.number += 1;
}

最佳答案

或者,您可以将您的文字显示为图像循环。该代码允许您指定图像集更新的速度。因此,与其使用文本对象,不如构建一组图像,将其安装在 watch 上,然后循环显示它们。

关于ios - 在 iPhone 和 Apple Watch 之间发送数据时减少延迟的策略?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30112437/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com