在tableview中滑动删除功能无法正常工作

时间:2017-03-09 18:30:28

标签: ios uitableview firebase swift3 firebase-realtime-database

我刚刚将滑动删除功能添加到我的tableview控制器。但是不能正常工作。它会删除Firebase数据库中的项目。但它不会删除我的tableview控制器中的行。摆脱行的唯一方法是重新启动整个应用程序。我的代码中缺少什么?

var CourtDictionary = [String: Courts]()

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    print(indexPath.row)

 let Platz = self.Platzlist[indexPath.row]

    if let CourtID = Platz.PlatzID {

        FIRDatabase.database().reference().child("Sportplatz").child(CourtID).removeValue(completionBlock: { (error, ref) in
            if error != nil {
                print("Fehler beim Löschen",error!)
                return
            }
            self.CourtDictionary.removeValue(forKey: CourtID)
            self.tableView.reloadData()
        })



    }

editRow函数设置为true。该应用程序根本没有崩溃。但是,就tableview控制器而言,似乎没有调用delete函数。

0 个答案:

没有答案
相关问题