8

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.

JiteshW
  • 2,195
  • 4
  • 32
  • 61
LK.
  • 4,499
  • 8
  • 38
  • 48

1 Answers1

1

You just forgot to check one condition

[UIView animateWithDuration:2 
                 animations:^{ 
                     [childViewController_.view setAlpha:0];  
                 } 
                 completion:^(BOOL finished) {
                     if (finished)
                     {
                          [childViewController_.view removeFromSuperview];
                     }
                 }];
Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76