如何使用Swipe方法进行TableView编辑

问题描述 投票:0回答:1

我正在使用leadingSwipeActionsConfigurationForRowAt 方法进行滑动。我还在这里使用拖放功能。

在这种情况下,属性 tableview.editing 为 true。然后我就无法得到滑动的回调了。

func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

}
swift tableview uiswipegesturerecognizer
1个回答
0
投票

您必须返回一个

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
}
© www.soinside.com 2019 - 2024. All rights reserved.