开发者

What does the finished parameter in the completion block mean in animateWithDuration

开发者 https://www.devze.com 2023-04-11 12:40 出处:网络
I\'m trying to understand how view animations work in iOS; i currently have an animation that i create with:

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 reaso开发者_运维问答n 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号