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...
}];
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...
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With