gpt4 book ai didi

ios - tableView delete动画仅在从底部删除时有效

转载 作者:行者123 更新时间:2023-11-30 13:15:21 24 4
gpt4 key购买 nike

我从表视图中删除行的动画仅在我从表底部删除时才有效,如果我从顶部或中间删除,则单元格动画仅适用于最后一个单元格(如果我要从底部删除)对于所有,感谢您的帮助!

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com