Reputation: 3820
This is the classic animation, but I need to know when it actually finishes. thanks
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame];
campFireView.frame = CGRectMake(255.0f,0.0f,512.0f,384.0f);
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"wish_launch_up_low_00000.png"],
[UIImage imageNamed:@"wish_launch_up_low_00001.png"],
[UIImage imageNamed:@"wish_launch_up_low_00002.png"],
[UIImage imageNamed:@"wish_launch_up_low_00003.png"],
[UIImage imageNamed:@"wish_launch_up_low_00004.png"],
[UIImage imageNamed:@"wish_launch_up_low_00005.png"],
,nil];
campFireView.animationDuration = 0;
campFireView.animationRepeatCount = 1;
[campFireView startAnimating];
[self.view addSubview:campFireView];
Upvotes: 0
Views: 145
Reputation: 1706
It is pain to detect UIImageView animation.. but if you don't mind mess you can do something like this..
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame];
campFireView.frame = CGRectMake(255.0f,0.0f,512.0f,384.0f);
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"wish_launch_up_low_00000.png"],
[UIImage imageNamed:@"wish_launch_up_low_00001.png"],
[UIImage imageNamed:@"wish_launch_up_low_00002.png"],
[UIImage imageNamed:@"wish_launch_up_low_00003.png"],
[UIImage imageNamed:@"wish_launch_up_low_00004.png"],
[UIImage imageNamed:@"wish_launch_up_low_00005.png"],
,nil];
campFireView.animationDuration = 4; // <--- I changed the duration..
campFireView.animationRepeatCount = 1;
[campFireView startAnimating];
[self.view addSubview:campFireView];
...
// detect it with timer
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
-(void)OnTimer {
if ( [campFireView isAnimating] )
{
// still animating
}
else
{
// Animating done
}
}
this is just an example but if your animation duration is less then timer you can check it with timer to validate isAnimating...
However, there are many option to animate other the UIImageView...
Upvotes: 1