WatchKit图像动画等待完成 [英] WatchKit Image Animation wait for finish

查看:209
本文介绍了WatchKit图像动画等待完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I currently looking for a way to wait to finish my Image Animation and then start the next one after it is finished.

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

I thought to use a completion handler but it "does not work for me" is there a way to use it in that case?

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动画何时结束。

You have to create a timer that is the same duration as the animation and wait for the timer to fire to know when the WatchKit animation has finished.

以下是Apple在Apple开发论坛上对此问题的回复。

Here is Apple's response to this question on the Apple dev forums.


目前还不知道动画何时结束,因为
我们还没有在WatchKit的API中公开完成处理程序。如果您愿意,请在 http://bugreport.apple.com 上提交
增强请求
看到添加的内容。过去,您可以使用所描述的方法,
只是意识到它可能无法在所有
情况下工作。您可以选择更改您的用户界面,如果您需要它,
始终是现货。

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 。基本上使用计时器并不完美,但它是你最好的。

You can read the full thread here https://devforums.apple.com/message/1087798#1087798. Basically using a timer isn't perfect, but it is the best you have.

这篇关于WatchKit图像动画等待完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆