ios - WatchKit 图像动画等待完成

标签 ios image swift watchkit

我目前正在寻找一种方法来等待完成我的图像动画,然后在完成后开始下一个。

我想使用完成处理程序,但它“对我不起作用”,在这种情况下有没有办法使用它?

if X > 1 {
            self.GroupIMG.setBackgroundImageNamed("single")
            self.GroupIMG.startAnimatingWithImagesInRange(NSRange(location: 0, length: 300), duration: Repeater, repeatCount: self.X)

        }



//this should start after the if is done

            self.GroupIMG.setBackgroundImageNamed("single")
            self.GroupIMG.startAnimatingWithImagesInRange(NSRange(location: 0, length: leftX), duration: Repeater, repeatCount: 1)

最佳答案

您必须创建一个与动画持续时间相同的计时器,并等待计时器触发以了解 WatchKit 动画何时结束。

这是 Apple 在 Apple 开发者论坛上对这个问题的回应。

There is not a way to currently know when an animation has ended, as we haven't exposed a completion handler in WatchKit's API. Please file an enhancement request at http://bugreport.apple.com if you'd like to see something added. Past that, you can use the method described, just be aware that it may not work as you like under all circumstances. You may choose to alter your UI if you need need it to always be spot on.

您可以在此处阅读完整主题 https://devforums.apple.com/message/1087798#1087798 .基本上,使用计时器并不完美,但它是您所拥有的最好的。

关于ios - WatchKit 图像动画等待完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29498214/

相关文章:

ios - 在 XCode 中的某个循环后运行断点?

ios - 我必须使用哪种SampleBuffer方法来测量帧率?

python - 通过python在图像上编写复杂的自定义元数据

c++ - Qt 从文件中打开图像 - 如何知道图像大小

ios - 使用 CGColorSpaceCreateDeviceGray() 将彩色 UIImage 转换为灰度

iphone - Interface Builder 对象库中缺少对象

image - 模拟设备背光对人类图像感知的影响

swift - 为什么我无法在 Realm 对象上设置属性?

ios - 您能否以编程方式在应用程序中允许推送通知?

ios - 如何使用 AVFoundation 和相机 View 更改 fps 并隐藏状态栏