相关疑难解决方法(0)

UITableViewRowAction与UISwipeActionsConfiguration

这两个API似乎获得了相同的结果。在哪种情况下,最好使用一种而不是另一种?

override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
  let deleteAction = UITableViewRowAction(style: .destructive,
                                          title: "Delete") { (action, indexPath) in
    print("DELETE")
  }
  return [deleteAction]
}
Run Code Online (Sandbox Code Playgroud)
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
  let DeleteAction = UIContextualAction(style: .destructive, title: "Delete", handler: { (action, view, success) in
      print("Delete")
  })
  DeleteAction.backgroundColor = .red
  return UISwipeActionsConfiguration(actions: [DeleteAction])
}
Run Code Online (Sandbox Code Playgroud)

ios swift

5
推荐指数
1
解决办法
589
查看次数

标签 统计

ios ×1

swift ×1