我正在使用leadingSwipeActionsConfigurationForRowAt 方法进行滑动。我还在这里使用拖放功能。
在这种情况下,属性 tableview.editing 为 true。然后我就无法得到滑动的回调了。
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
}
您必须返回一个
UISwipeActionsConfiguration
对象,如下例所示:
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let firstAction = UIContextualAction(style: .normal, title: "First Action", handler: { (action, view, done) in
// Do stuff here
done(true) // completion handler
})
let secondAction = UIContextualAction(style: .normal, title: "Second Action", handler: { (action, view, done) in
// Do stuff here
done(true) // completion handler
})
let config = UISwipeActionsConfiguration(actions: [firstAction, secondAction])
config.performsFirstActionWithFullSwipe = true
return config
}