UITableView NSInternalInconsistencyException错误抛出;一个单元格的两个动画

时间:2012-04-07 02:19:10

标签: iphone ios cocoa-touch uitableview

我有一个UITableView,我想在UITableViewController中编辑。这段代码来自我调用tableView的方法。

    [self.tableView beginUpdates];
    [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject: path] withRowAnimation:UITableViewRowAnimationNone];
    [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject: path] withRowAnimation:UITableViewRowAnimationNone];

    NSMutableArray *things = [[self.fetchedResultsController fetchedObjects] mutableCopy];

    self.storedCell = [things objectAtIndex: path.row];

    [things removeObjectAtIndex: path.row];

    for ( int i = 0; i < [things count]; i++) {
        Task *mo = (Task *)[things objectAtIndex: i];
        [mo setValue:[NSNumber numberWithInt: i] forKey:@"displayOrder"];
    }
    [things release]; things = nil;
    self.newPath = path;

    [self.managedObjectContext save: nil]; 
    [self.tableView endUpdates];

这是抛出的错误:

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempt to create two animations for cell'

关于我做错了什么的任何想法?

1 个答案:

答案 0 :(得分:3)

而不是删除然后插入同一行,如果这是您想要做的,只需重新加载它:

[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:path] withRowAnimation:UITableViewRowAnimationNone];

但是,您似乎应该删除该行,因此您可能只需删除insertRowsAtIndexPaths行。 (当然,你没有发布所有代码,所以我不确定......)