现在左划可以滑倒最左边,就删除了数据,这么做可以不允许滑倒最左边用的是这个方法的默认实现
tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath)

解决方案 »

  1.   

        func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
            return true
        }
        
        func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {
            return "删除"
        }实现这两个协议方法应该就不会了,我就是这么用的
      

  2.   

    向左拖会出现 return “删除--” 返回的字符串,点击会删除,但还是可以直接拖到最左边,我这里需要不让它可以拖到最左边,怎么弄?
      

  3.   

    请阅读这个文档
    https://developer.apple.com/documentation/uikit/uiswipeactionsconfiguration通过tableViewDelegate的tableView(_:trailingSwipeActionsConfigurationForRowAt:)回调方法可以返回一个UISwipeActionsConfiguration对象,而该对象可以指定:var performsFirstActionWithFullSwipe: Bool
    A Boolean value indicating whether a full swipe automatically performs the first action.来支持“划到边缘自动执行‘的行为