2010-10-06 111 views
0

我试图在我的UITableViewCell子类上添加一个连续的动画。 这是一个相当简单的一与图像淡入淡出(0.4α和1.0之间的衰落), 我到目前为止已经试过IST以下:UITableViewCell中的连续动画

-(void)animateRecordingIndicator{ 

    [UIView beginAnimations:@"RecordingIndicatorAnimation" context:nil]; 
    [UIView setAnimationDuration:0.3]; 

    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(animationFinished)]; 

    if (animatedImageView.alpha == 0.4) 
     animatedImageView.alpha = 1.0; 
    else 
     animatedImageView.alpha = 0.4;  

    [UIView commitAnimations]; 
} 

内animationFinished的代码如下:

-(void)animationFinished{ 
    if (doShowAnimation) { 
     [self performSelectorOnMainThread:@selector(animateRecordingIndicator) withObject:nil waitUntilDone:YES]; 
    } 
} 

我预计应该是现在很清楚的话,但我所得到的仅仅是在Xcode装载Stackframes崩溃或多或少eternaly :)

我对每样的建议非常感激,TIPP或诀窍如何处理这一点。

在此先感谢,

SAM

+0

我回答之前的快速问题,iOS3兼容性是强制性的吗? – 2010-10-06 13:47:44

+0

不是真的,我只是在运行低于4.1或4.0的设备上忽略动画 – samsam 2010-10-06 13:51:41

回答

1

按照UIView class reference,你现在使用的commitAnimations方法气馁。而是使用以下内容:

animateWithDuration:delay:options:animations:completion: 

我想你遇到的无限递归与苹果公司提出该建议的理由有关。

+0

感谢您的提示,现在它的动画。遗憾的是,在动画开始之后应用程序块并不再可能用户输入。也只有n个tableViewCells中的第一个才能使动画起作用。 – samsam 2010-10-07 08:42:55