LK.
LK.

Reputation: 4569

animation completion called immediately

I have the following animation block:

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

When performed as above, the completion block is called immediately. If I don't have the completion block however, then the animation is performed as expected.

What am I doing wrong here?

Update
The finished flag in the completion block is NO.

Upvotes: 8

Views: 3364

Answers (1)

Nirav Gadhiya
Nirav Gadhiya

Reputation: 6342

You just forgot to check one condition

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

Upvotes: 1

Related Questions