【问题标题】:Apple Watch animation broke after 1.0.1Apple Watch 动画在 1.0.1 之后中断
【发布时间】:2015-05-28 08:51:06
【问题描述】:

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

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

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

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

应用运行时,图片是静态的,即只显示spin0

任何想法为什么?

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

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

【问题讨论】:

    标签: ios objective-c animation watchkit


    【解决方案1】:

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

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

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

    IB-screenshot

    【讨论】:

    • 看起来像资源复制问题。您是否尝试过从项目中删除动画帧并重新添加它们或将它们移动到观看应用资产目录?
    • 是的,所有图片都包括在内。第一次调用 awakeWithContext 时似乎没有动画 - 我有一个强制触摸手势调用 awakeWithContext 来刷新,动画在这种情况下有效
    • 哦,猜猜awakeWithContext 不是开始动画的正确位置。尝试将其移动到控制器的willActivate 中。请参阅 developer.apple.com/library/ios/documentation/General/… 的 WatchKit 应用生命周期
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 2016-05-15
    • 1970-01-01
    • 2015-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多