Watch OS2中的图像动画不起作用

时间:2015-10-21 03:20:24

标签: ios watchkit apple-watch watch-os-2

我正在尝试为WKInterfaceGroup的背景图像设置动画而不成功。我知道这很简单,不应该做太多,但我仍然无法使图像生动。

我在资产中加载了六个图像,名为loading1~loading 6。

我在IB中设置了群组,并在outlet中定义了WKInterfaceController

我正在使用的代码如下:

    // Defined outlet from IB    
@property (unsafe_unretained, nonatomic) IBOutlet WKInterfaceGroup *mainGroup;

...

[self.mainGroup setBackgroundImageNamed:@"loading1"];

NSRange range = {1,6};
[self.mainGroup startAnimatingWithImagesInRange:range duration:0.5f repeatCount:0];

这没有任何作用。没有显示图像。如果我删除了startAnimatingImagesInRange:duration:repeatCount:方法调用,则会显示图像loading1,但正如预期的那样,它不会设置动画。

我也试过在IB中设置动画并从代码中调用startAnimating,但它仍然具有相同的行为(当调用startAnimating图像消失时)。

注意:我在模拟器中尝试这个,因为我还没有Watch(您认为这可能是问题吗?)。

1 个答案:

答案 0 :(得分:4)

更改

:

[self.mainGroup setBackgroundImageNamed:@"loading1"];