I have a a check that is run in my code. If the check returns true, I execute an animation and display a UIAlertView to the user. My problem is that i don’t know how to delay the UIAlertView until the animation is completed. So, currently, the UIAlertView is displayed and the animation is seen running in the background. I’d appreciate any help with this. Here is the relevant code:
BOOL isComplete = [self checkJigsawCompleted:droppedInPlace withTag:tag];
if (isComplete) {
[stopWatchTimer invalidate];
stopWatchTimer = nil;
[self updateTimer];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
imgGrid.alpha = 0;
imgBackground.alpha = 0;
[UIView commitAnimations];
NSString *completedMessage = [NSString stringWithFormat:@"You completed the puzzle in: %@", lblStopwatch.text];
UIAlertView *jigsawCompleteAlert = [[UIAlertView alloc] //show alert box with option to play or exit
initWithTitle: @"Congratulations!"
message:completedMessage
delegate:self
cancelButtonTitle:@"I'm done"
otherButtonTitles:@"Play again",nil];
[jigsawCompleteAlert show];
}
Switch to the blocks-based animation method: