我有一個tableview用來自對象數組的數據填充。對象具有的價格,名稱,等等等等刪除動畫完成後更新TableView
當細胞被刪除的數據源(陣列)被更新,並且該行使用UITableViewRowAnimationFade滑落屏幕。
當一個項目被刪除某些性能,如價格,陣列中的對象可以改變,所以我因此需要更新所有單元的屏幕上作爲其數據可能已經改變。
我看過了的文檔,發現reloadRowsAtIndexPaths:withRowAnimation,我可以用indexPathsforVisibleRows結合起來,重新加載屏幕上的行,但內的tableView這樣做:commitEditingStyle:forRowAtIndexPath看起來真的很討厭,因爲它試圖執行刪除動畫,同時還重裝...
是否有等待刪除動畫執行任務之前完成的方法嗎?
這裏是我的ViewController
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// update the datasource
[self.dataController deleteItemAtIndex:indexPath.row];
// update the table
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
// reload the table to show any changes to datasource from above deletion
[self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows] withRowAnimation:UITableViewRowAnimationNone];
}
}
ASD
抱歉,但並沒有真正幫助,因爲模型仍然會通知控制器,同時刪除動畫正在採取導致同樣的事情發生的地方。 –
刪除是用戶交互還是代碼操作的結果? – Tobi
如果這是用戶操作的結果(用戶點擊「編輯」按鈕,刪除一些單元格並離開編輯模式),則可以覆蓋tableVC的setEditing:animated :.當用戶正在編輯時,您會跟蹤他所做的更改,並且當用戶將編輯模式設置爲NO(即他再次點擊編輯按鈕)時,您更新數據源 – Tobi