删除和编辑 swift 中 tableView 中的行
DELETE and EDIT with row in tableView in swift
我正在尝试在行上进行幻灯片编辑和删除按钮。但是,它不起作用。该按钮根本不显示,我在网上尝试了很多示例。生成按钮的代码在我的代码底部。
class DetailViewController: UIViewController {code.................}
extension DetailViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
{
let deleteAction = UIContextualAction(style: .destructive, title: "Delete") { (action, view, handler) in
//YOUR_CODE_HERE
print("HELLO")
}
deleteAction.backgroundColor = UIColor.yellow
let configuration = UISwipeActionsConfiguration(actions: [deleteAction])
return configuration
}
}
如果您需要更多信息,请告诉我。
而不是
tableView(_:editActionsForRowAt:)
实施
tableView(_:trailingSwipeActionsConfigurationForRowAt:)
class DetailViewController: UIViewController {code.................}
//inside (code......) we have to add
sensorTableView.delegate = self
sensorTableView.dataSource = self
我仍然不知道代码是什么意思,但如果滑动按钮没有反应,这将起作用
我正在尝试在行上进行幻灯片编辑和删除按钮。但是,它不起作用。该按钮根本不显示,我在网上尝试了很多示例。生成按钮的代码在我的代码底部。
class DetailViewController: UIViewController {code.................}
extension DetailViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
{
let deleteAction = UIContextualAction(style: .destructive, title: "Delete") { (action, view, handler) in
//YOUR_CODE_HERE
print("HELLO")
}
deleteAction.backgroundColor = UIColor.yellow
let configuration = UISwipeActionsConfiguration(actions: [deleteAction])
return configuration
}
}
如果您需要更多信息,请告诉我。
而不是
tableView(_:editActionsForRowAt:)
实施
tableView(_:trailingSwipeActionsConfigurationForRowAt:)
class DetailViewController: UIViewController {code.................}
//inside (code......) we have to add
sensorTableView.delegate = self
sensorTableView.dataSource = self
我仍然不知道代码是什么意思,但如果滑动按钮没有反应,这将起作用