我已将自定义动画添加到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