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

标签 ios swift animation tableview

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

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/

相关文章:

ios - 如何在不使用 segues 的情况下使用委托(delegate)和协议(protocol)将数据从以编程方式创建的 UIPopoverController 传递到 ViewController?

使用 Xib 和 Swift 进行 iOS 本地化 : Can someone help me to make an multilingual app using XIB (not Storyboard) and Swift?

ios - 隐藏堆栈 View 时,并非所有内容都会在堆栈 View 中进行动画处理

ios - 使用 UIImage 放大 ScrollView

ios - 如何快速双击(而不是单击) Collection View 单元格?

ios - UITableViewCell 不显示 Swift 中的内容

iphone - UIView动画结束

ios - Swift - 使用 selectedIndex 更改 var

ios - 检查用户是否存在于 Firebase 中不起作用 - Swift

c++ - Vector & Stack Overflow - Part Deux