2012-04-07 110 views
2

我有一個UITableView,我想在UITableViewController中編輯。這段代碼來自我調用編輯tableView的方法。UITableView NSInternalInconsistencyException錯誤拋出;一個單元格的兩個動畫

[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' 

任何想法對我做了什麼錯?

+0

這是什麼運氣? – lnafziger 2012-04-13 03:30:50

+1

是的重新調用工作,感謝您的幫助! – geenen124 2012-04-13 19:30:53

回答

3

不用刪除,然後插入同一行,如果這是你想要做什麼,只是重新加載它:

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

但是,它看起來像你應該只刪除該行,所以你或許應該只是刪除insertRowsAtIndexPaths行。 (當然,你沒有發佈所有的代碼,所以我不知道肯定....)

相關問題