iOS 13.0中不推荐使用UITableViewRowAction

时间:2019-06-19 11:43:16

标签: ios swift uitableview swift4

我正在尝试升级项目代码,并发现此警告

 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]
}

2 个答案:

答案 0 :(得分:0)

您可以在UISwipeActionsConfiguration上使用UITableViewRowAction,例如

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

  return UISwipeActionsConfiguration()
}

答案 1 :(得分:0)

  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
}