0

For iOS11 am not able to use custom delete button in table row by using trailingSwipeActionsConfigurationForRowAt delegate method. i think am missing something but what it is i don't know.Following method was not called on swipe of row.Any help would be appreciated.

@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

    let deleteAction = UIContextualAction.init(style: UIContextualAction.Style.destructive, title: nil, handler: { (action, view, completion) in
        //TODO: Delete
        completion(true)
    })
    deleteAction.backgroundColor = .blue//UIColor(red: 252/255, green: 56/255, blue: 88/255, alpha: 1.0)
    deleteAction.image = UIGraphicsImageRenderer(size:CGSize(width:30,height:30)).image { _ in
        UIImage(named: "Icon-Trash")!.draw(in : CGRect(x:0,y:0,width:30,height:30))
    }
    let config = UISwipeActionsConfiguration(actions: [deleteAction])
    config.performsFirstActionWithFullSwipe = false
    return config
}

Anyone can post working code for iOS11 because i already tried from my end.

Sumit Jangra
  • 651
  • 5
  • 16

1 Answers1

0

I resolved it by setting datasource and delegate of tableview by code instead of storyboard.Also i update all of the delegate method in swift4.

Sumit Jangra
  • 651
  • 5
  • 16