WKInterfaceImage 中真的存在 animationDidStop 吗?

Does animationDidStop actually exist in WKInterfaceImage?

在我的 WatchKit 项目中,我有一个图像,我想在 startAnimatingWithImagesInRange 启动的动画完成时执行一个方法。 Xcode提示WKInterfaceImage中存在animationDidStop方法。 但是,我在 WKInterfaceImage reference 中找不到它,这让我很失望。那么,这是错误还是不是错误,我该如何使用该方法?或者我应该使用 NSTimer?

执行一些解决方法

新答案

我认为您在 Xcode 中发现了一个错误。如您所述,文档并未显示 WKInterfaceImage 符合 CAAnimation 或其代表。这是我在操场上做的一个小测试,以确认这是一个问题:

// Documented Methods
WKInterfaceImage.instancesRespondToSelector(Selector("startAnimating")) // returns true
WKInterfaceImage.instancesRespondToSelector(Selector("stopAnimating")) // returns true

// Undoscumented Methods
WKInterfaceImage.instancesRespondToSelector(Selector("animationDidStart:")) // returns false
WKInterfaceImage.instancesRespondToSelector(Selector("animationDidStop:")) // returns false

因此,即使它自动完成,我也不认为这些方法会受到影响,因为 WatchKit 没有附带 CAAnimation 支持或 CAAnimation 的替代方法。

旧答案

WKInterfaceImage上有一个stopAnimation方法:

https://developer.apple.com/library/ios/documentation/WatchKit/Reference/WKInterfaceImage_class/index.html#//apple_ref/occ/instm/WKInterfaceImage/stopAnimating