I'm trying to display 34 consecutive images in a UIImageView container when a button is pressed.
- (IBAction)buttonPressed {
[self updateUI:(0)];
}
-(void)updateUI:(int)yesser{
//if GO is pressed
//display 34 images MG_8842.PNG -> MG_8875.PNG stored in Supporting Files
for(int j = 0;j<34;j++){
NSString *newPhoto =[NSString stringWithFormat:@"MG_88%i.PNG",42+j];
NSLog(@"%@",newPhoto);
sleep(1);
[self setNextImage:newPhoto];
}
}
-(void)setNextImage:(NSString*)nextImage{
[ball performSelectorOnMainThread:@selector(setImage:) withObject: [UIImage imageNamed:nextImage] waitUntilDone:YES];
}
However, images are not updating. When all the code finishes and returns, the first image is displayed.
I've tried the following:
1) Product > Clean
2) Reinstalled app.
3) Checked all case sensitivity.
4) Tested number of methods for setting UIImageView images.
5) Checked if 34 static NSString values worked instead of changing one NSString each time
6) Removed and re-added images to supporting files folder.
7) Renamed all images and updated code to match.
8) Turned AutoLayout off.
Any help would be GREATLY appreciated.
Thanks, Rob
sleep()would cause you more issues than help. Couldn't you just use anNSTimerand schedule it to callsetNextImage:every second? - SpacePyro