动画完成立即调用

LK.*_*LK. 8 iphone ipad uiviewanimation objective-c-blocks

我有以下动画块:

[UIView animateWithDuration:2 
                 animations:^{ 
                     [childViewController_.view setAlpha:0];  
                 } 
                 completion:^(BOOL finished) {
                     [childViewController_.view removeFromSuperview];
                 }];
Run Code Online (Sandbox Code Playgroud)

当如上执行时,立即调用完成块.但是,如果我没有完成块,则按预期执行动画.

我在这做错了什么?

更新完成块中
finished标志是NO.

Nir*_*iya 1

您只是忘记检查一个条件

[UIView animateWithDuration:2 
                 animations:^{ 
                     [childViewController_.view setAlpha:0];  
                 } 
                 completion:^(BOOL finished) {
                     if (finished)
                     {
                          [childViewController_.view removeFromSuperview];
                     }
                 }];
Run Code Online (Sandbox Code Playgroud)