I have an edit button, that you swipe right to see, that takes you to another ViewController. But when I swipe right it instantly takes me to the ViewController instead of revealing the edit button (Sometimes I get a glimpse of the edit button before it takes me there). Is there a way to slow this down or remedy this? I'm using 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])
Move this code:
let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)
let vc : UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "FreshReleaseAdd") as UIViewController
self.present(vc, animated: true, completion: nil)
...to just before success(true)
. It needs to be what you do when the button is tapped, not something you do now.