How to edit tableview cell on TAP instead of swipe – Swift

I have a UITableViewController and at the moment, the user can swipe left on the cell to reveal an ‘add to favourites’ button. I would now like to add an icon to the cell that the user can tap to reveal the this button (does the same thing as swiping to the left). This will just act as a visual aid for the users who do not know swiping left will do the same thing.

For my TableView, I use the following code to ‘close the cell’ when the user has pressed the button:

  • UICollectionView inside a UITableViewCell — dynamic height?
  • UITableView selected cell doesn't stay selected when scrolled
  • Objective-C: How to list files from documents directory into a UITableView?
  • Best approach for editing text fields in a table view cell
  • UITableViewCell Reuse and Images Re-render
  • How to set Action for UIButton in UITableViewCell
  • itemsTableView.setEditing(false, animated: true)
    

    From this I assumed that to manually open the cell I would simply call:

    //Get cell
    let cell:TableViewCell = itemsTableView.cellForRowAtIndexPath(NSIndexPath(forRow: 
    sender.tag, inSection: 0)) as! TableViewCell 
    
    //Open cell to reveal button
    cell.setEditing(true, animated: true)
    

    Unfortunately this does not work. So I would like to know what is the function that is called when a user swipes to the left of a cell and how can I replicate it when a user taps on the icon?

    Solutions Collect From Internet About “How to edit tableview cell on TAP instead of swipe – Swift”

    I don’t think you’re going to be able to do it, sorry. This feature relies on the UITableView’s pan gesture recognizer. When the user pans sideways, the table view checks the editActions... delegate method and, if we have edit actions, inserts a private confirmation view behind the cell and allows the cell to be moved to reveal it. You can’t trigger that behavior programmatically as far as I can tell.

    This would be a reason — one of many very good reasons — for sticking with a third-party scrollable cell class. In this way, the cell is a horizontal scroll view and you just scroll it in code.