我将我的 tablerowactions 更新为 swift 4 等效项,以便能够将图标而不是文本设置为当用户在表格元素上向左滑动时显示的按钮。我的问题是,如果用户从右向左滑动而不是仅显示所有可用操作,则第一个定义的操作(在我的情况下为删除操作)会自动触发。我想停用此行为。我的代码目前看起来像这样:
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let deleteAction = UIContextualAction(style: .normal, title: "", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
// implemantion of delete-button here
// ...
success(true)
})
deleteAction.image = #imageLiteral(resourceName: "deleteIcon")
deleteAction.backgroundColor = .red
return UISwipeActionsConfiguration(actions: [deleteAction])
}