UITableView에서 행을 삭제하려고 할 때 어설 션 오류 오류 오류
-
13-12-2019 - |
문제
때로는 UITableView에서 행을 분리하려고 할 때이 오류가 발생합니다.
어설 션 실패 - [UITableView _endcellanimationSwithContext :]
및 기타 시간은 문제가없는 행을 삭제합니다.
여기에 내 코드가 있습니다 :
- (void) tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[[self displayedObjects] removeObjectAtIndex:[indexPath row]];
// Animate deletion
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
[[self tableView] deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
}
}
. 해결책
numberOfrowsinsection 이 편집 모드를 입력 할 때 잘못된 정수를 반환하는 것처럼 잘못된 것입니다.
다른 팁
그렇게 확실하지 않은 .. 그러나 이것을 시도하십시오 (한 번 나를 위해 일했습니다)
먼저 UITableView h 제를 애니메이션 한 다음 객체를 배열에서 제거합니다.
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// Animate deletion
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
[[self tableView] deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
[[self displayedObjects] removeObjectAtIndex:[indexPath row]];
}
. 제휴하지 않습니다 StackOverflow