我已將自定義動畫添加到UITableViewCells。每個單元格都有自己的動畫。當我彈出視圖時,動畫繼續,並且由於動畫試圖訪問釋放的單元格,導致執行錯誤。iPhone:如何停止視圖中的動畫視圖釋放前
如何在釋放視圖之前停止動畫?
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
self.Currentcell = [tableView cellForRowAtIndexPath:indexPath];
[UIView beginAnimations:@"fade" context:nil];
[UIView setAnimationDuration:0.4];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[self.Currentcell.accessoryView viewWithTag:1].alpha = 0;
[self.Currentcell.accessoryView viewWithTag:2].alpha = 1;
[UIView setAnimationDidStopSelector:@selector(animationEnded:finished:context:)];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
- (void)animationEnded:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView beginAnimations:animationID context:context];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[cell.accessoryView viewWithTag:1].alpha = 1;
[cell.accessoryView viewWithTag:2].alpha = 0;
[UIView commitAnimations];
}
你能告訴我一些例子如何停止動畫? – RAGOpoR 2010-03-23 14:37:45
其實我不能,因爲你沒有發佈任何代碼,所以我不知道你如何創建和處理你的動畫。發佈您的代碼,以便我們可以看到發生了什麼,並嘗試找出解決方案。 – Matthes 2010-03-23 14:55:03
更新它!感謝您的建議 – RAGOpoR 2010-03-23 15:29:05