0

I'm trying to run this animation which is working fine, but I want the last number to stay on the screen. currently it runs through the array then disappears.. is there anyway to stop the animation on the number that is passed in?

- (void)playAnimationToNumber:(int)number{

    NSMutableArray *imagesForAnimation = [[NSMutableArray alloc] initWithCapacity:0];


    for (int counter=1; counter<=number; counter++) {

        NSString *imageNameForFirstNumber = [NSString stringWithFormat:@"Flap%i.png", counter];
        [imagesForAnimation addObject:[UIImage imageNamed:@"FlapMoving1.png"]];
        [imagesForAnimation addObject:[UIImage imageNamed:@"FlapMoving2.png"]];
        [imagesForAnimation addObject:[UIImage imageNamed:imageNameForFirstNumber]];
    }
    animationArray.animationImages = [NSArray arrayWithArray:imagesForAnimation];        

    animationArray.animationDuration = 1.2;
    animationArray.animationRepeatCount = 1;
    [animationArray startAnimating];
    [self.view addSubview:animationArray];
    [imagesForAnimation release];


}
HurkNburkS
  • 5,492
  • 19
  • 100
  • 183

2 Answers2

0

According to UIImageView startAnimating: How do you get it to stop on the last image in the series? the image that is shown after the animation ends is given in the "image" property. So something like this should do the trick:

animationArray.image = [imagesForAnimation lastObject];
Community
  • 1
  • 1
Bemmu
  • 17,849
  • 16
  • 76
  • 93
  • I believe the problem is that the last image that should be set to the .image property is included to animation together with the 'fade out' effect image, then the problem is not to include the last 'fade out' image to animation array. – A-Live Jun 18 '11 at 10:19
0
        for (int counter=1; counter<number; counter++) {
        ...
        }
        [imagesForAnimation addObject:[UIImage imageNamed:@"FlapMoving1.png"]];
        [imagesForAnimation addObject:[UIImage imageNamed:[NSString stringWithFormat:@"Flap%i.png", number]]];

iterating to the all images but the last (counter) and then adding the last image to the animation array should help. tell me how it works.

A-Live
  • 8,904
  • 2
  • 39
  • 74