A frequently answered question, I'm afraid but I am pretty much in the dark on this.
Within my view controller I have the following method to switch back and forward between two images a total of 5 times
- (IBAction)cycle{
BOOL select1;
select1=YES;
UIImage *image1 = [UIImage imageNamed:@"image1.png"];
UIImage *image2 = [UIImage imageNamed:@"image2.png"];
for (int i=0; i<5; i++) {
if (select1){
[imageview setImage:image1];
} else {
[imageview setImage:image2];
}
[NSThread sleepForTimeInterval:1.0];
[imageview setNeedsDisplay];
}
}
The problem is that the setNeedsDisplay message does not work within the loop and the view is only updated when the method quits.
Is there any thing I can do here? Is the approach feasible or am I completely down the wrong track. This is very much a test program (I am new to this language) but it would be useful to control something like this programmatically. The next step app will implement randomly changing times between picture changes.
Can anyone help me on this?