I am trying to so a simple UIImageView animation. I have 11 images of .png type. The animation is just a rabbit blinking. I am having issues with the array:
UIImageView *animationView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width/2-123/2, self.view.bounds.size.height/2-278/2, 123, 278)];
NSArray *imageNames = [NSArray arrayWithObjects:@"rabbit-1.png",@"rabbit-2.png",@"rabbit-3.png",@"rabbit-4.png",@"rabbit-5.png",@"rabbit-6.png",@"rabbit-7.png",@"rabbit-8.png",@"rabbit-9.png",@"rabbit-10.png",@"rabbit-11.png", nil];
NSMutableArray *images = [[NSMutableArray alloc] init];
for(int x =0; x==[imageNames count]; x++){
UIImage *image = [UIImage imageNamed: [imageNames objectAtIndex:x]];
[images addObject:image];
}
NSLog(@"image name array length is : %d",[images count]);
animationView.animationImages=images;
animationView.animationDuration=10;
[self.view addSubview:animationView];
[animationView startAnimating];
Nothing is appearing on the screen because the images array is empty. Not sure why this is. I did init and alloc in it but when I check the length it comes back as zero. Any ideas what is going on here? Any pointers would be appreciated. Thanks
x == [imageNames count]
is always false, so the for loop won't get executed.Change the line
to