1. 程式人生 > >解決 Assertion failure in -[UITableView _endCellAnimationsWithContext:] 問題

解決 Assertion failure in -[UITableView _endCellAnimationsWithContext:] 問題

找了幾種方法

1,

[_tableView beginUpdates];  
[_tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];  
[_tableView endUpdates];  
在delete之前和之後加上beginUpdates和endUpdate

事實證明對我沒什麼用!

2,

在刪除之前先刪除掉資料來源中的資料

[self.datas removeObject:self.datas[indexPath.row]];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationBottom];
ok了!

就是在呼叫deleteRowsAtIndexPaths:方法前,要確保資料為最新