有时在尝试从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];

    }
}
.

有帮助吗?

解决方案

声音像你的 numberofrowsection 有时输入编辑模式时返回错误的整数。

其他提示

不太确定..但尝试这个(为我工作一次)

首先动画UITableView删除,然后从数组中删除对象。

if (editingStyle == UITableViewCellEditingStyleDelete)
    {
     // Animate deletion
     NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
     [[self tableView] deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];

    [[self displayedObjects] removeObjectAtIndex:[indexPath row]];

    }
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top