Why is the image animation not appearing?

Discussion in 'iOS Programming' started by Aptlymade, Oct 21, 2012.

  1. Aptlymade, Oct 21, 2012
    Last edited by a moderator: Oct 21, 2012

    Aptlymade macrumors newbie

    Joined:
    Oct 21, 2012
    #1
    It creates an image and animates it... while it is animation it moves to the other corner basically... the image is not appearing at all... it worked before I added the array in so im guessing theres something wrong with the array maybe placement because all code seems to be logical... also if i replace the entire array with just something like UIImage *image = [UIImage imageNamed:mad:"x"]; it works fine.. thanks

    Code:
    int x = arc4random()%5+1;
    UIImage *one = [UIImage imageNamed:@"1.png"];
    UIImage *two = [UIImage imageNamed:@"2.png"];
    UIImage *three = [UIImage imageNamed:@"3.png"];
    UIImage *four = [UIImage imageNamed:@"4.png"];
    UIImage *five = [UIImage imageNamed:@"5.png"];
    UIImage *six = [UIImage imageNamed:@"6.png"];
    UIImage *seven = [UIImage imageNamed:@"7.png"];
    UIImage *eight = [UIImage imageNamed:@"8.png"];
    UIImageView *alienFlyer = [[UIImageView alloc]init];
    alienFlyer.animationImages = [NSArray arrayWithObjects:
    one,
    two,
    three,
    four,
    five,
    six,
    seven,
    eight, nil];
    
    alienFlyer.animationDuration = 1;
    alienFlyer.animationRepeatCount = -1;
    
    
    [alienFlyer setFrame:CGRectMake((-alienFlyer.bounds.size.width)-1, ((self.view.bounds.size.height)-(alienFlyer.bounds.size.height))/2, alienFlyer.frame.size.width, alienFlyer.frame.size.height)];
    [self.view addSubview:alienFlyer];
    [alienFlyer startAnimating];
    CGRect theMoveToPosition = CGRectMake(((self.view.bounds.size.width)+(alienFlyer.bounds.size.width))+1, ((self.view.bounds.size.height)-(alienFlyer.bounds.size.height))/2, alienFlyer.frame.size.width, alienFlyer.frame.size.height);
    [UIView animateWithDuration:x delay:0 options:UIViewAnimationOptionTransitionCurlUp
    animations:^ {
    alienFlyer.frame = theMoveToPosition;
    }completion:^(BOOL finished) {
    if (finished) {
    [alienFlyer removeFromSuperview]; 
    
    }
    }];
    
    
    }
     
  2. Reason077 macrumors 68000

    Reason077

    Joined:
    Aug 14, 2007
    #2
    animationRepeatCount should be 0 (not -1) if you want the animation to repeat indefinitely. Trying fixing that and see if it helps.
     

Share This Page