I have a basic timer set up for record the time it takes to complete my custom animation.
- (void) performAnimationOfFrameAtIndex:(NSNumber*)indexNum
{
int index = indexNum.intValue;
BOOL completedSequece = index >= [self.frames count];
if (completedSequece) {
BOOL repeatsRemaining = self.currentCycleCount < self.cyclesRepeatsValue;
if (repeatsRemaining) {
self.currentCycleCount ++;
index = kFirstFrame;
}
else {
self.methodEnd = [NSDate date];
[self logDurationToComplete];
return;
}
}
UIImageView *imgIn;
UIImageView *imgOut;
if (index % 2 == 0) {
imgIn = self.animationImageViewOne;
imgOut = self.animationImageViewTwo;
}
else {
imgIn = self.animationImageViewTwo;
imgOut = self.animationImageViewOne;
}
imgIn.image = self.frames[index];
[self.view sendSubviewToBack:self.imgOut];
double speed = (index < self.frames.count * 0.5) ? self.inspirationDuration : self.expirationDuration;
[self performSelector:@selector(performAnimationOfFrameAtIndex:) withObject:[NSNumber numberWithInt:index + 1] afterDelay:speed];
}
I have set it to take 1.0 seconds
Why does the first run through take 1.2 -> 1.6 seconds, and the following take 1.0 seconds.
If it set it to 2 seconds, the first run takes 2.2 -> 2.6 seconds...
If set to 3 seconds it takes 3.0 seconds on first run, so
Time Profiler indicated that
imgIn.image = self.frames[index];
Is consuming 100% of the time, I have tried setting imgIn.image as a property and setting in viewDidLoad, but no change with the first run delay.
All images have been preloaded in viewDidLoad.
No difference on simulator or device, method call begins using IBAction
Thanks for any ideas...