3049

UIView animation using 90%CPU

Question:

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]; } ];

Answer1:

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.

Recommend