0

I am beginner of iphone, I have all images in array but how to display one by one when I execute the array in a loop..

NSArray *images = [[NSArray arrayWithObjects:   
                        [UIImage imageNamed:@"1.png"],
                        [UIImage imageNamed:@"2.png"],
                        [UIImage imageNamed:@"3.png"],
                        [UIImage imageNamed:@"4.png"],
                        nil] retain];  


 int i=0;
    int width = 0;
    int height = 0;
    for ( NSString *imageName in images )
    {
        //NSTimer *timer=[[NSTimer alloc]init];
        UIImage *image = [images objectAtIndex:i];
        //UIImage *image = [UIImage imageNamed:imageName];
        animalphoto = [[UIImageView alloc] initWithImage:image];
        animalphoto.contentMode = UIViewContentModeScaleAspectFit;
        animalphoto.clipsToBounds = YES;



        animalphoto.animationDuration=5.0;
        animalphoto.animationRepeatCount=0;

        animalphoto.frame = CGRectMake( animalphoto.frame.size.width * i++, 0, animalphoto.frame.size.width, animalphoto.frame.size.height);


       width = animalphoto.frame.size.width;
        height = animalphoto.frame.size.height;
        NSLog(@"print:%@",image);
        [animalphoto release];
    }


}

Give any suggestion and sample code which is apply in our code..

1
  • Use this method : imgView.animationImages = images; Commented Jul 5, 2012 at 11:13

2 Answers 2

1

Instead of putting one image just put whole array of images to the imgview.animationImages = images without the for loop

For further reference visit this site.

Sign up to request clarification or add additional context in comments.

Comments

0

you need to use UIImageView's object animationImages to set the UIImage array
set animationRepeatCount
set animationDuration
then call [imageView startAnimating]; to start the animation

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.