iOS:Tableview开始更新从不播放animation

我写了一些代码,当用户长按一个单元格并确认更改时,从后端和本地数据存储中删除一个post。 但是,tableview不会更新。 我已经突破了我的代码和tableView操作代码被执行,为什么我的行不被从视图中删除?

let alertView = UIAlertController(title: "Really?", message: "Are you sure you want to delete this post? Once you do it will be gone forever.", preferredStyle: .Alert) alertView.addAction(UIAlertAction(title: "Delete Post", style: UIAlertActionStyle.Default, handler: { (alertView:UIAlertAction!) -> Void in let p = post.getRawPost() p.deleteInBackgroundWithBlock({ (deleted:Bool, error:NSError?) -> Void in // Remove from the local datastore too p.fetchFromLocalDatastore() p.deleteInBackgroundWithBlock({ (deleted:Bool, error:NSError?) -> Void in // Update the table view self.tableView.beginUpdates() self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Left) self.tableView.endUpdates() }) }) })) 

据我所知, beginUpdatesendUpdates用于更新tableView的特定部分,而不需要在源上执行完整的reloadData调用。 我在这里错过了什么?

更新我将tableView更新代码移动到主线程,每当endUpdates时,都会产生崩溃。 我的新代码如下所示,并在主线程中调用:

 self.tableView.beginUpdates() self.tableView.deleteRowsAtIndexPaths([NSIndexPath(forRow: indexPath.row, inSection: indexPath.section)], withRowAnimation: UITableViewRowAnimation.Automatic) self.tableView.endUpdates() 

将下面的代码片段封装MAIN THREAD中

 self.tableView.beginUpdates() self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Left) self.tableView.endUpdates() 

编辑崩溃

 p.deleteInBackgroundWithBlock({ (deleted:Bool, error:NSError?) -> Void in // Remove from the local datastore too p.fetchFromLocalDatastore() // Delete the desired item from array ... // Remove cell that the item belong to animated in main thread dispatch_async(dispatch_get_main_queue(), { // Update the table view self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Left) }) })