Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewRowAction was deprecated in iOS 13.0 [duplicate]

I am trying to upgrade code of my project and found this warning

 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
    let deleteRowAction = UITableViewRowAction(style: .destructive, title: deleteActionTitle) { [unowned self] (_, indexPath) in
        //code you want to execute        }
    return [deleteRowAction]
}
like image 548
user1828845 Avatar asked Jun 19 '19 11:06

user1828845


2 Answers

  func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
    let contextItem = UIContextualAction(style: .destructive, title: deleteActionTitle) {  (contextualAction, view, boolValue) in
        //Code I want to do here 
    }
    let swipeActions = UISwipeActionsConfiguration(actions: [contextItem])

    return swipeActions
}
like image 187
user1828845 Avatar answered Oct 23 '22 03:10

user1828845


You can use the UISwipeActionsConfiguration over UITableViewRowAction such as

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

  return UISwipeActionsConfiguration()
}
like image 39
Anupam Mishra Avatar answered Oct 23 '22 03:10

Anupam Mishra