animateWithDuration 中完成块中的 finish 参数是什么意思
我试图了解 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着由于某种原因动画没有完成。例如,该视图可能已从其超级视图中删除,或者可能已对其应用了另一个动画,或者是 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.