本文介绍了为什么领先的滑动动作也被复制为尾随动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的 tableView 上实现了一个前导滑动操作(删除"),由于我无法弄清楚的原因,它也显示为尾随滑动操作.见下面的代码:
I have implemented a leading swipe action ('Delete') on my tableView which for a reason I can't figure out is also appearing as a trailing swipe action. See code below:
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) ->
UISwipeActionsConfiguration? {
let delete1 = deleteAction(at: indexPath)
return UISwipeActionsConfiguration(actions: [delete1])
}
func deleteAction(at indexPath: IndexPath) -> UIContextualAction {
let action = UIContextualAction(style: .destructive, title: "Delete") { (action, view, completion) in
self.delete(at: indexPath)
}
return action
}
我曾经有一个拖尾滑动操作,但我完全删除了这个功能.当我将 'leadingSwipeActionsConfigurationForRowAt' 更改为 'trailingSwipeActions...' 时,只会出现尾随滑动操作.如果有人能告诉我我错过了什么,不胜感激.谢谢.
I used to have a trailing swipe action, but I deleted this function out completely. When I change 'leadingSwipeActionsConfigurationForRowAt' to 'trailingSwipeActions...' then only the trailing swipe action appears. Be grateful if anyone could tell me what I've missed. Thanks.
推荐答案
使用此代码防止trailingSwipeAction()
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle
{
return .none
}
- 或
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
return UISwipeActionsConfiguration(actions: [])
}
这篇关于为什么领先的滑动动作也被复制为尾随动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!