在看到按钮之前发生滑动动作 - Swift 编码

Swipe Action Happens Before Seeing Button - Swift Coding

我有一个编辑按钮,您可以向右滑动查看,它会将您带到另一个 ViewController。但是当我向右滑动时,它会立即将我带到 ViewController 而不是显示编辑按钮(有时我会在它把我带到那里之前瞥见编辑按钮)。有没有办法减慢或解决这个问题?我正在使用 Swift.

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

{
    let modifyAction = UIContextualAction(style: .normal, title:  "Update", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
        print("Update action ...")
        success(true)

    })
    modifyAction.title = "Edit"
    modifyAction.backgroundColor = .blue

    let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)
    let vc : UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "FreshReleaseAdd") as UIViewController
    self.present(vc, animated: true, completion: nil)

    return UISwipeActionsConfiguration(actions: [modifyAction])

移动此代码:

let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)
let vc : UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "FreshReleaseAdd") as UIViewController
self.present(vc, animated: true, completion: nil)

...到 success(true) 之前。它需要是你在点击按钮时所做的事情,而不是你现在所做的事情。