animateWithDuration 中完成块中的 finish 参数是什么意思

发布于 2024-12-08 08:19:49 字数 560 浏览 0 评论 0原文

我试图了解 iOS 中视图动画的工作原理;我目前有一个我创建的动画:

+ (void)animateWithDuration:(NSTimeInterval)duration
                      delay:(NSTimeInterval)delay
                    options:(UIViewAnimationOptions)options
                 animations:(void (^)(void))animations
                 completion:(void (^)(BOOL finished))completion

但是我有一个关于完成块中完成参数的问题;完成的参数是什么,我有点理解,如果完成是是,动画实际上发生了,这是一件好事,但是当它设置为否时意味着什么以及处理这个问题的常见方法是什么通常,特别是如果您想链接在同一视图上工作的动画(在完成块中调用下一个动画)?

我问的原因是因为它有时会返回“否”,原因我不清楚,因为视图存在于视图层次结构中并且没有其他动画介入。

I'm trying to understand how view animations work in iOS; i currently have an animation that i create with:

+ (void)animateWithDuration:(NSTimeInterval)duration
                      delay:(NSTimeInterval)delay
                    options:(UIViewAnimationOptions)options
                 animations:(void (^)(void))animations
                 completion:(void (^)(BOOL finished))completion

But I've got a question concerning the finished parameter in the completion block; what the finished parameter does i somewhat understand in the sense that if finished is YES the animation actually happened which is a good thing, but what does it mean when it is set to NO and what is the common way to deal with this normally, especially if you want to chain animations (calling a next animation in the completion block) that work on the same view?

The reason I ask is because it returns NO at sometimes for reasons unclear to me, as the view is present in the view hierarchy and there are no other animations intervening.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心欲静而疯不止 2024-12-15 08:19:49

这意味着由于某种原因动画没有完成。例如,该视图可能已从其超级视图中删除,或者可能已对其应用了另一个动画,或者是 Apple 熟知的许多其他原因。你如何处理它取决于你。您可以再次启动整个动画链,从上一个动画或下一个动画开始。

It means that for some reason or another the animation did not complete. The view could have been removed from its superview for example or another animation could have been applied to it, or a number of other reasons best known to Apple. How you deal with it is up to you. You could start the entire animation chain again, start at the last animation, or the next.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文