编辑按钮-Swift-UIViewController

编辑按钮-Swift-UIViewController,swift,uitableview,uiviewcontroller,edit,Swift,Uitableview,Uiviewcontroller,Edit,我不熟悉Swift语言,也不熟悉一般的编码。我使用代码在中编写了一个编辑按钮: { let modifyAction = UIContextualAction(style: .normal, title: "Update", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in print("Update action ...") success(tru

我不熟悉Swift语言,也不熟悉一般的编码。我使用代码在中编写了一个编辑按钮:

{
    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

    return UISwipeActionsConfiguration(actions: [modifyAction])
}
按下时,我需要“编辑”按钮转到此UIViewController:

AddfreshreleaseViewController:UIViewController

我该怎么写呢

更新

我正在尝试将编辑按钮链接回我的UIViewController(AddfreshreleaseViewController)。当您向右滑动单元格时,此代码在左侧显示编辑按钮,但当我添加“performSegue”以尝试返回UIViewController时,每次我现在向编辑按钮滑动时,应用程序都会崩溃。有什么建议我可以让它工作吗

@available(iOS 11.0, *)
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

performSegue(withIdentifier: "addFreshRelease", sender: self)

return UISwipeActionsConfiguration(actions: [modifyAction])

}

根据我在按下按钮时的理解,您希望转到另一个窗口(UIViewController),因此必须创建一个
segue
,并在
ui按钮中添加:

performSegue(withIdentifier: <YOUR_IDENTIFIER>, sender: self)
performsgue(标识符为,发件人为self)

嘿。。。你试过解决方案了吗?我试过了,你的代码很有用!但我希望当我向右滑动电池时,这个按钮会显示出来。所以,除了我已经要让按钮显示的代码外,我不知道如何在视图中设置。应该作为另一个问题来问这个问题。好吧,我提供的代码使得当你向右滑动单元格时,它会显示一个编辑按钮。我只是不知道如何使编辑按钮将您带回AddfreshreleaseViewController页面。尝试此操作时,我遇到了错误:无法将类型为“AddfreshreleaseViewController.type”的值转换为预期的参数类型“String”,但我给UIViewController一个标题以修复该错误。它现在可以构建了,但当我按下那个按钮时,应用程序崩溃了。