ios - Apple Watch 动画在 1.0.1 后崩溃

标签 ios objective-c animation watchkit

我在 WKInterfaceTable 中的 WKInterfaceImage 中有一个动画:

[[self.table setNumberOfRows:1 withRowType:@"Loading"];
WatchLoadingCell *cell = [self.table rowControllerAtIndex:0];

[cell.image setImageNamed:@"spin"];
[cell.image startAnimating];

我的图像被命名为 spin0 - spin30 并被添加到 watchKit App 目标。

当应用程序运行时,图像是静态的,即只显示 spin0

有什么想法吗?

编辑:它适用于模拟器,但不适用于设备本身,只有当我通过调用 [self awakeWithContext:nil]; 从我的 Force Touch 菜单重新加载 View 时,它才适用于设备

我也试过在 willActivate 中启动动画,但没有成功

最佳答案

在代码中设置动画图片时,应该使用startAnimatingWithImagesInRange:duration:repeatCount:方法

[cell.image setImageNamed:@"spin"];
[cell.image startAnimatingWithImagesInRange:NSMakeRange(0, 30) duration:10 repeatCount:0];

如果调用 startAnimating 方法,将使用 IB 中设置的持续时间

IB-screenshot

关于ios - Apple Watch 动画在 1.0.1 后崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30501592/

相关文章:

objective-c - Obj-C 使用 isKindOfClass 确定整数值

iphone - 如何停止 UIScrollView 调用 drawRect : on sublayers that go in/out of the visible region?

ios - 通过 CocoaPods 安装 Realm

ios - Swift 类函数在 for-in 循环后返回空

ios - 为什么 block 被设计为在堆栈上分配,除非被复制?

javascript - jQuery 中滚动时闪烁的图像序列

javascript - 如何在 p5.js 中制作动画?

ios - 在表格 View 自定义单元格中的图像上长按手势

ios - 带 pan 1.0 的 Obj-C EZAudioPlot

iphone - 远程唤醒应用程序,比如从蓝牙设备