Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在滑动单元格时,如何隐藏其他滑动单元格操作_Ios_Swift_Uitableview_Swipe - Fatal编程技术网

Ios 在滑动单元格时,如何隐藏其他滑动单元格操作

Ios 在滑动单元格时,如何隐藏其他滑动单元格操作,ios,swift,uitableview,swipe,Ios,Swift,Uitableview,Swipe,我有一个带有本机SwipeCell功能的tableView。 当用户稍微滑动单元格时,我有两个操作(删除和编辑)。 当您一直滑动单元格时,它将移动删除按钮(如预期的那样),问题是-背景是透明的,因此当删除按钮位于编辑图标上方时,它看起来很糟糕 @available(iOS 11.0, *) func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath)

我有一个带有本机SwipeCell功能的tableView。 当用户稍微滑动单元格时,我有两个操作(删除和编辑)。 当您一直滑动单元格时,它将移动删除按钮(如预期的那样),问题是-背景是透明的,因此当删除按钮位于编辑图标上方时,它看起来很糟糕

@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
    let deleteAction = UIContextualAction(style: .normal, title: nil) { [weak self] (action, view, complete) in

        self?.deleteAction(tableView, at: indexPath)
        complete(true)
    }
    if let cgImageX =  #imageLiteral(resourceName: "alarmDelete").cgImage {
        deleteAction.image = ImageWithoutRender(cgImage: cgImageX, scale: UIScreen.main.nativeScale, orientation: .up)
    }
    deleteAction.backgroundColor = UIColor.white.withAlphaComponent(0)

    let editAction = UIContextualAction(style: .normal, title: nil) { [weak self] (action, view, complete) in
        self?.editAction(tableView, at: indexPath)
        complete(true)
    }
    if let editImage =  #imageLiteral(resourceName: "edit").cgImage {
        editAction.image = ImageWithoutRender(cgImage: editImage, scale: UIScreen.main.nativeScale, orientation: .up)
    }
    editAction.backgroundColor = UIColor.white.withAlphaComponent(0)
    return UISwipeActionsConfiguration(actions: [deleteAction, editAction])
}
移动单元格时是否可以隐藏其他操作?

视频:


谢谢

您应该按如下方式更新代码以解决问题

let swipeActionConfig = UISwipeActionsConfiguration(actions: [deleteAction, editAction])
swipeActionConfig.performsFirstActionWithFullSwipe = false
return swipeActionConfig

但是,这将阻止第一个操作以完全滑动的方式执行,这意味着您无法在将单元格滑动到“所有操作后显示更多”时执行第一个操作。

您应该按照以下方式更新代码以解决问题

let swipeActionConfig = UISwipeActionsConfiguration(actions: [deleteAction, editAction])
swipeActionConfig.performsFirstActionWithFullSwipe = false
return swipeActionConfig

但是,这将阻止第一个操作以完全滑动的方式执行,意味着您无法在将单元格滑动到“所有操作后显示更多”时执行第一个操作。

请发布您尝试过的任何操作的代码。添加了定义操作的函数,还没有找到解决此问题的任何方法,因此此
deleteAction
的任何其他代码都不是常量和方法?您可以发布方法的代码吗?请发布您尝试过的代码。添加了定义操作的函数,但没有找到任何方法来解决此问题,因此此
deleteAction
的其他代码既不是常量,也不是方法?你能把方法的代码贴出来吗?