Reputation: 175
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..
Upvotes: 0
Views: 229
Reputation: 5267
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.
Upvotes: 1
Reputation: 8109
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
Upvotes: 0