1
// Animate moving the cards into position
    [UIView animateWithDuration:0.5
                          delay:0.0
                        options:UIViewAnimationOptionCurveLinear
                     animations: ^{ card.frame = cardFrame; }
                     completion: ^ (BOOL finished) {
                         if (finished) {
                             [UIView animateWithDuration:1.0
                                                   delay:3.0
                                                 options:UIViewAnimationOptionTransitionFlipFromRight
                                              animations: ^ { card.image = [UIImage imageNamed:@"imgBack.png"]; }
                                              completion:NULL];
             }
                     }];

for some reason the second delay just won't delay. and the animation continues instantly any help?

Mazyod
  • 22,319
  • 10
  • 92
  • 157
rc1ironman
  • 45
  • 3

1 Answers1

2

The problem you are having actually has nothing to do with nesting. UIImageView simply cannot animate the setImage: property, and hence the code is executed as soon as it is reached.

If you are OK with simply delaying setting the image property, then go ahead and use:

double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    card.image = newImage;
});

If you are looking to animate the image changing, you might wanna look into CATransition, and apply a transition effect to images changing within the image view.

Mazyod
  • 22,319
  • 10
  • 92
  • 157
  • Thanks for the help. I think i'm going to look into CATransition as i would like to animate the change as it would look a bit more user friendly. – rc1ironman Aug 09 '13 at 20:33