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...
}];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.