0

I have this code for my animation:

facebookImage.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"Animation01.png"],
                                 [UIImage imageNamed:@"Animation02.png"],
                                 [UIImage imageNamed:@"Animation03.png"],
                                 [UIImage imageNamed:@"Animation04.png"],
                                 [UIImage imageNamed:@"Animation05.png"],
                                 nil];
facebookImage.animationDuration = 1.3;
facebookImage.animationRepeatCount = 1;
[facebookImage startAnimating];

How do I use delegate callback (or something else) for doing something after this animation is complete?

I can't do this :

[UIView setAnimationDelegate:self];

because I don't have this option in UIImageview

thanks :)

ShinTakezou
  • 9,432
  • 1
  • 29
  • 39
Asi G
  • 15
  • 5
  • Actually `UIImageView` is a subclass of `UIView` so it inherits `setAnimationDelegate:`. – Espresso Jan 06 '14 at 01:45
  • check this http://stackoverflow.com/questions/9283270/access-method-after-uiimageview-animation-finish hope it helps you – stosha Jan 06 '14 at 01:45
  • http://stackoverflow.com/questions/7772988/ios-how-to-detect-when-an-animation-is-finished – Jessedc Jan 06 '14 at 01:45

1 Answers1

0

just add like this:

float animationDuration = 1.3;
facebookImage.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"Animation01.png"],
                                 [UIImage imageNamed:@"Animation02.png"],
                                 [UIImage imageNamed:@"Animation03.png"],
                                 [UIImage imageNamed:@"Animation04.png"],
                                 [UIImage imageNamed:@"Animation05.png"],
                                 nil];
facebookImage.animationDuration = animationDuration;
facebookImage.animationRepeatCount = 1;
[facebookImage startAnimating];
[self performSelector:@selector(someMethodDelayedToEndOfAnimation) withObject:nil afterDelay: animationDuration];
Refael.S
  • 1,634
  • 1
  • 12
  • 22
  • Thank you - Refael.S - it works, but how can i pass an argument if i want to run method like this: -(IBAction)movingObjectDown : (UIImageView *) myObj – Asi G Jan 06 '14 at 03:13
  • 1
    try using like [self performSelector:@selector(movingObjectDown:) withObject:myObj afterDelay: animDuration]; – Shankar BS Jan 06 '14 at 04:09
  • First movingObjectDown receives UIImageView so it is useless to state it as IBAction, no button will call this action. It will work because IBAction is also like void. Just change it to void and do [self performSelector:@selector(movingObjectDown:) withObject:myObj afterDelay: animDuration]; as commented already (; – Refael.S Jan 06 '14 at 06:12
  • thank you shan + refael s. you r the best ;) – Asi G Jan 06 '14 at 18:08
  • @Refael.S - i'm new in this site. what do you mean "up vote the answer"? i'v selected the green "V" on your answer. :) let me know in private or here :) – Asi G Jan 07 '14 at 22:17
  • @AsiG on top of the "V" there are two arrows, the top one pressed gives an up vote. – Refael.S Jan 07 '14 at 22:48