简体   繁体   中英

UIView animation completion block execute immediately

-(void)methodXXXX {

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

I call this method at -viewDidAppear , while it directly call completion block .

Why? Is there any strange things ive missed?

I found one more wired thing:

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

Use below code.

-(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;
    }];
}
[UIView animateWithDuration:11 delay:"add some delay and try" options:0 animations:^{

} completion:^(BOOL finished) {

}];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM