我从表视图中删除行的动画仅在我从表底部删除时才有效,如果我从顶部或中间删除,则单元格动画仅适用于最后一个单元格(如果我要从底部删除)对于所有,感谢您的帮助!
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
tableView.beginUpdates()
let app = UIApplication.sharedApplication().delegate as! AppDelegate
let context = app.managedObjectContext
context.deleteObject(quotesArray[indexPath.row])
self.quotesArray.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
tableView.endUpdates()
self.tableView.reloadData()
do {
try context.save()
} catch _ {
}
}
}
最佳答案
删除beginUpdates,endUpdates和reloadData起作用
关于ios - tableView delete动画仅在从底部删除时有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38291057/