gpt4 book ai didi

ios - UIView 动画完成 block 立即执行

转载 作者:行者123 更新时间:2023-11-29 10:28:25 56 4
gpt4 key购买 nike

-(void)methodXXXX {

[UIView animateWithDuration:11 animations:^{
//...some animation changes...
} completion:^(BOOL finished) {
[_fallBtn removeFromSuperview];
_fallBtn = nil;
}
}];
}

我在-viewDidAppear调用这个方法,而它直接调用completion block

为什么?我错过了什么奇怪的事情吗?

我又发现了一件有线的东西:

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = YES; //If set YES, it will directly call -animationDidStop method; if NO, the animation execute while never call -animationDidStop
pathAnimation.duration = 10;
pathAnimation.delegate = self; //here I implement the -animationDidStop method

最佳答案

使用下面的代码。

-(void)viewDidAppear:(BOOL)animated {
[self performSelector:@selector(methodXXXX) withObject:nil afterDelay:0.1f];
}

-(void)methodXXXX {

[UIView animateWithDuration:11 animations:^
//...some animation changes...
} completion:^(BOOL finished) {
[_fallBtn removeFromSuperview];
_fallBtn = nil;
}];
}

关于ios - UIView 动画完成 block 立即执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30938314/

56 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com