8

I want to run a block of code after an animation is completed but the compiler shows the following error : "Incompatible block pointer types sending 'void (^)(void)' to parameter of type 'void (^)(BOOL)'"

Here is my code, I am not sure what I am doing wrong, please help, thanks.

[UIView transitionWithView:self.view duration:1.5
                   options:UIViewAnimationOptionTransitionFlipFromBottom //change to whatever animation you like
                animations:^ {
                    [self.view addSubview:myImageView1];
                    [self.view addSubview:myImageView2];
                }
                completion:^ {
                    NSLog(@"Animations completed.");
                    // do something...
                }];
lostAtSeaJoshua
  • 1,695
  • 2
  • 21
  • 34
Fellow GEEK
  • 81
  • 1
  • 2

1 Answers1

14

You just have the wrong block type :) It needs a block like below. The key being ^(BOOL finished) {...}

[UIView transitionWithView:self.view duration:1.5
                   options:UIViewAnimationOptionTransitionFlipFromBottom //change to whatever animation you like
                animations:^ {
                    [self.view addSubview:myImageView1];
                    [self.view addSubview:myImageView2];
                }
                completion:^(BOOL finished){
                    if (finished) {
                        // Successful
                    }
                    NSLog(@"Animations completed.");
                    // do something...
                }];
Ryan Poolos
  • 18,421
  • 4
  • 65
  • 98