2012-02-03 70 views
1
[[PeopleManager shared] removePersonAtIndex:indexPath.row withGroupIndex:currentGroupIndex]; 

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationNone]; 

PeopleManager類有一個人數組(NSMutableArray)。使用動畫刪除單元格時發生錯誤

我的錯誤不是索引值錯誤。

它工作正常99.9%沒有錯誤。但有時會出現錯誤

錯誤代碼

2012-02-03 17:17:53.232電話簿[343:707] *在 斷言故障 - [UITableView的_endCellAnimationsWithContext:],/ SourceCache/UIKit/UIKit-1912.3/UITableView.m:1046 2012-02-03 17:17:53.239 PhoneBook [343:707] *由於未捕獲異常'NSInternalInconsistencyException',原因: '終止應用程序無效更新:無效數第0部分中的行。現有部分中包含的 行的數目日期(1)必須爲 ,其等於 更新(1)之前該節中包含的行數,加上或減去插入或從 該節(插入0個,刪除1個)和加或減的行數移入或移出該部分的行數爲 (移入0,移出0)。 終止叫拋異常技能

如何解決它?我讀錯誤code.but我不知道如何解決它...

回答

0

你應該換你deleteRows ...調用在beginUpdates和endUpdates對:

[tableView beginUpdates]; 
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationNone]; 
[tableView endUpdates]; 

,並確保您的numberOfRowsForSection :方法返回正確的更新值

相關問題