ios - 带有图像错误的 AppleWatch 圆形进度(或径向弧进度)
<p><p>我正在使用 WatchKit 为 Apple Watch 开发应用程序,我需要在录制音频时实现循环进度,类似于 Apple 演示。</p>
<p>我不知道 WatchKit 是否默认包含某些功能,因此我创建了自己的图像(13 个 12 秒 [总共 209 KB]),并用计时器进行更改。</p>
<p>这是我的源代码:</p>
<p><strong>开始/停止录制的按钮操作</strong></p>
<pre><code>- (IBAction)recordAction {
NSLogPageSize();
NSLog(@"Recording...");
if (!isRecording) {
NSLog(@"Start!");
isRecording = YES;
_timerStop = [NSTimer scheduledTimerWithTimeInterval:12.0
target:self
selector:@selector(timerDone)
userInfo:nil
repeats:NO];
_timerProgress = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(progressChange)
userInfo:nil
repeats:YES];
} else {
NSLog(@"Stop :(");
;
}
}
</code></pre>
<p><strong>计时器结束或再次点击按钮时的操作</strong></p>
<pre><code>-(void) timerDone{
NSLog(@"timerDone");
;
_timerProgress = nil;
];
counter = 0;
isRecording = NO;
}
</code></pre>
<p><strong>改变进度的方法</strong></p>
<pre><code>- (void)progressChange
{
counter++;
NSLog(@"%d", counter);
NSString *image = ;
;
NSLog(image);
}
</code></pre>
<p>这是一个显示错误的 gif。它开始显示但随机更改图像,直到它得到几秒钟。 (注意:我已经检查过第一张图片的进度是否正确)</p>
<p> <img src="/image/a1G6v.gif" alt="Screen recording that shows my bug"/> </p>
<p><strong>更新(其他解决方案):使用 startAnimating</strong></p>
<p>有一种新方法可以使用 <em>startAnimatingWithImagesInRange:duration:repeatCount</em></p> 来显示圆圈的进度
<p>您需要指定动画的图像范围和持续时间。请参阅下面的示例:</p>
<pre><code>;
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我相信这是 WatchKit 解释图像名称方式的副作用。</p>
<p>以数字结尾的图像名称用于表示动画图像中的帧,因此“ic_playing_elipse_12_10”被解释为名为“ic_playing_eclipse_12_1”的图像的第一帧,当您希望它显示第一个图像时会显示第 10 个图像一个。</p>
<p>您应该可以只更改图像名称,这样数字就不是图像名称的最后一部分,它会修复它。</p></p>
<p style="font-size: 20px;">关于ios - 带有图像错误的 AppleWatch 圆形进度(或径向弧进度),我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/29284104/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/29284104/
</a>
</p>
页:
[1]