0

Currently, I have a swipe action in my TableView to perform a custom action on swipe on the corresponding cell. However, I'd like to change how far I have to drag to get the default haptic feedback to indicate completion of swipe. Also, I would like to add a feature that hides the swipe action automatically if the action is not completed instead of it remaining on screen. Here's my code so far:

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

    let customRowAction = UIContextualAction(style: .normal, title: "Action") {(action, view, completed)  -> Void in

        //perform updates to data

        completed(true)

    }

    let configuration = UISwipeActionsConfiguration(actions: [customRowAction])

    return configuration
}

I'd like to achieve an effect similar to that of the Apollo reddit app. Any help would be appreciated!

  • @matt I tried that but it didn’t work (I placed it below the completed(true) line). – Mansur Ahmed Feb 17 '19 at 01:08
  • @matt correct me if I’m wrong, but whatever is in the customRowAction closure is only called once you’ve swiped far enough to get the default haptic feedback and release the swipe. With that in mind, what I’d like to achieve is getting the rowAction to hide if the user lets go of the swipe before getting that haptic feedback. I apologize for not making that clear. – Mansur Ahmed Feb 17 '19 at 01:58

1 Answers1

1

The design details of the built in row swipe mechanism are not up to you. Either live with them or don’t use them at all (and write your own swipe mechanism from scratch).

matt
  • 515,959
  • 87
  • 875
  • 1,141