0

hi i have animation which loop but are using 90% of my iphone CPU processing and are heating up the phone. what have i done wrong ?

anybody can give me some advise ?

thanks

-(void)nextAnimation:(float)previousWidth {

//picture loop
imageViewTop.image = imageViewBottom.image;
imageViewBottom.image = [imageArray objectAtIndex:[imageArray count] - 1];

[imageArray insertObject:imageViewBottom.image atIndex:0];
[imageArray removeLastObject];
imageViewTop.alpha = 1.0;
imageViewBottom.alpha = 0.0;

[UIView animateWithDuration:4.0
                 animations:^{ 
                     imageViewTop.alpha = 0.0;
                     imageViewBottom.alpha = 1.0;
                     } 
                 completion:^(BOOL  completed){
                     [self nextAnimation:stringsize.width];
                 }
 ]; 
Desmond
  • 5,001
  • 14
  • 56
  • 115

1 Answers1

1

You got a infinite loop in you code. You must have a quit condition to avoid infinite loop. A static counter is zero, and run one time add 1, if counter > n quit.

Tinyfool
  • 1,460
  • 2
  • 18
  • 40
  • is it because is an infinite loop that cause the high CPU ? i need it to be looping till location are found and replace it with something else – Desmond Dec 05 '11 at 10:06
  • I think maybe is, you can add a NSLog at nextAnimation to see how many time it runs, to see if it like what you want. – Tinyfool Dec 05 '11 at 10:11
  • I didn't see any wrong infinite loop in this code. The only loop is the needed animation loop. I'm doing that kind of code every day. I think there's another problem. – Mathieu Hausherr Dec 05 '11 at 10:30
  • not too sure, put in an NSLog, runs well but if i tab to another view.....the NSLOG keep logging every ms – Desmond Dec 05 '11 at 10:36
  • i believe is this line, if i commented it out... the CPU is fine. – Desmond Dec 05 '11 at 10:36