2010-10-06 108 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