In the following code, the NSTimer
interval is set at 1 second between each picture. My goal is to change the interval after the first two pictures, hello.png and b
The best/simpliest way :
-(void)Timer{
// Do what you want here
// modify the frequency value if you want.
[NSTimer scheduledTimerWithTimeInterval:frequence target:self selector:@selector(Timer) userInfo:nil repeats:NO];
}
Frequence is a variable that contains the interval. You just need to call Timer method by yourself the first time ;)
For you, it would give
-(void)changeImage{
if (counter == self.images.count - 1 )
counter = 0;
else
counter ++;
frequence = (counter < 2)?1:4;
self.animationImageView.image = self.images[counter];
[NSTimer scheduledTimerWithTimeInterval:frequence target:self selector:@selector(changeImage) userInfo:nil repeats:NO];
}