How to run code after transition UIViewWithView?

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

Here is my code, I'm not sure what I'm 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... }]; 
+8
ios objective-c uiview uiviewanimation
source share
1 answer

You just have the wrong block type :) He needs a block, as shown below. Key ^(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... }]; 
+12
source share

All Articles