UIView animation using 90%CPU

人盡茶涼 提交于 2019-12-12 02:48:47

问题


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

回答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.



来源:https://stackoverflow.com/questions/8383571/uiview-animation-using-90cpu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!