gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 11:06:16 25 4
gpt4 key购买 nike

我有一个编辑按钮,向右滑动即可看到,它会将您带到另一个 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)之前。它需要是您点击按钮时执行的操作,而不是您现在执行的操作。

关于swift - 在看到按钮之前发生滑动操作 - Swift 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52683055/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com