Я добавил пользовательскую анимацию в UITableViewCells. Каждая ячейка имеет свою анимацию. Когда я открываю представление, анимация продолжается, и я получаю неверную ошибку exec, потому что анимация пытается получить доступ к освобожденным ячейкам.
Как остановить анимацию до того, как представление будет освобождено?
- (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];
}