-(void)methodXXXX {
[UIView animateWithDuration:11 animations:^{
//...some animation changes...
} completion:^(BOOL finished) {
[_fallBtn removeFromSuperview];
_fallBtn = nil;
}
}];
}
我在-viewDidAppear
调用此方法,而直接调用完成块。
为什么呢?我错过了什么奇怪的事情?
我发现了另外一件事:
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
答案 0 :(得分:2)
使用以下代码。
-(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;
}];
}
答案 1 :(得分:0)
[UIView animateWithDuration:11 delay:"add some delay and try" options:0 animations:^{
} completion:^(BOOL finished) {
}];