Swift Firebase如何在TableView中滑动以删除消息

时间:2018-06-23 09:29:25

标签: ios swift firebase firebase-realtime-database

请如何在TableView中滑动以删除消息?

Firebase中的数据

data from firebase

 var sectionsArray = [NSDictionary?]()

代码super.viewDidLoad()

      databaseRef.child("Sections").queryOrdered(byChild: "name").observe(.childAdded, with: { (snapshot) in

        var key = snapshot.key
        let snapshot = snapshot.value as? NSDictionary
        snapshot?.setValue(key, forKey: key)


            self. sectionsArray.append(snapshot)

            self.TableView.insertRows(at: [IndexPath(row:self. sectionsArray.count-1,section:0)], with: UITableViewRowAnimation.automatic)
        }


    }

代码删除

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

    if editingStyle == .delete {

       // I want this code...

    }

}

0 个答案:

没有答案