Ive got about 5,000 images labeled image_1 through to image_5000 how can I create an animation that will cycle through each image and then repeat?
This is an iPhone application and is just for my personal use, any help is greatly appreciated.
Here is the code I am using, why is it not working.
//.h
@interface ViewController : UIViewController{
IBOutlet UIImageView *imageView;
int i;
}
@end
- (void)viewDidLoad
{
i = 0;
[NSTimer scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(loop)
userInfo:nil
repeats:YES];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)loop{
if (i<MAX_IMAGES) {
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image_%d.bmp",i]];
NSLog(@"Image:%d",i);
i+=1;
if (i >= MAX_IMAGES) {
i = 1;
}
}
}
I would use a NSTimer to load an image at a time into an UIIMageView. That way you can have controlled of the interval between images changes and minimized memory usage. Let me know if you need sample code.