DeleteRows 코드를 누를 때마다 업데이트 전후의 행 수가 동일해야한다는 예외가 발생합니다.TableView에서 행을 삭제할 때 예외가 발생했습니다.
이유 : 잘못된 업데이트 : 섹션 0의 행 개수가 잘못되었습니다. 업데이트 (3) 후 기존 섹션에 포함 된 행 수는 이전에 해당 섹션에 포함 된 행 수와 같아야합니다. 업데이트 (3), 해당 섹션에서 삽입되거나 삭제 된 행 수를 더하거나 뺍니다 (삽입 된 0, 삭제 된 1).
내 코드는 다음과 같습니다
public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
{
if (editingStyle == UITableViewCellEditingStyle.Delete)
{
tableView.DeleteRows(new [] { indexPath }, UITableViewRowAnimation.Fade);
// Remove the step from the set of calculations
_calculation.Steps.RemoveAt(indexPath.Row);
}
}
잘못된 순서로 내 DeleteRows 및 RemoveAt을하고 있다고 말한 것으로부터 깨달을 수있었습니다. 일단 내가 주문을 변경하면 괜찮 았어. 감사! –