Ios 移除删除按钮⛔️;在编辑模式下的表行上

Ios 移除删除按钮⛔️;在编辑模式下的表行上,ios,swift,uitableview,Ios,Swift,Uitableview,我正在努力学习Swift,但我的项目中有一个问题让我发疯。 我在parse.com提供的ViewController中有一个数据工作列表。我成功地实现了一个滑动功能,可以显示删除和编辑按钮。这很好。现在我希望用户能够对单元格重新排序。因此,我成功地实现了一个按钮,使表格进入编辑模式。我的两个问题是: 当我进入编辑模式时,我只希望能够对单元格重新排序,因为编辑和删除是通过滑动(通过“tableView(tableView:UITableView,EditActionsErrorWatIndeXPa

我正在努力学习Swift,但我的项目中有一个问题让我发疯。 我在parse.com提供的ViewController中有一个数据工作列表。我成功地实现了一个滑动功能,可以显示删除和编辑按钮。这很好。现在我希望用户能够对单元格重新排序。因此,我成功地实现了一个按钮,使表格进入编辑模式。我的两个问题是:

  • 当我进入编辑模式时,我只希望能够对单元格重新排序,因为编辑和删除是通过滑动(通过“tableView(tableView:UITableView,EditActionsErrorWatIndeXPath:NSIndexPath)”完成的.如何确保用户在编辑模式下,触摸自动提供的删除圆圈时,看不到用于删除和编辑的两个按钮

  • 是否可以完全删除删除圆圈?使用“UITableViewCellEditingStyle.None”也会禁用刷卡功能


  • 提前感谢!

    尽管人们可以通过滑动删除一行,但编辑模式下的删除按钮不应被删除。人们可能不知道滑动手势,并且通过移除删除按钮(他们在编辑模式下已经预期),应用程序变得更难使用

    如果确实要删除删除按钮,则必须实现委托方法
    tableView(\uu:editingStyleForRowAtIndexPath:)
    。在屏幕处于编辑模式时,您可以返回
    。在屏幕处于编辑模式时,无
    。在屏幕未处于编辑模式时,删除


    要启用重新排序,您必须实现数据源方法
    tableView(\uquo:canMoveRowAtIndexPath:)
    tableView(\uquo:moveRowAtIndexPath:toindepath:)

    您可以按照以下方法在编辑时移除删除图标:

    -(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
         return UITableViewCellAccessoryNone;
     }
    

    为了避免在左侧将set-UITableView isEditing设置为true时出现圆形红色的删除按钮,而在单击该按钮时不执行任何操作,对我来说最起码的操作是这样的(Swift 4,iOS 11)

    //避免使用单元格左侧的圆形红色删除按钮:

    func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool {
        return false
    }
    
    
    func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
        return .none
    }
    
    我还有这些功能,它们可能相互作用:

    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
        return savedTempTable.isEditing
    }
    
    // Including this function in the delegate enable left-swipe deleting
    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath)
    {
        if editingStyle == .delete {
            savedConversions.remove(at: indexPath.row)
        }
    }
    
    
    // Including this function enables reordering
    func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath,to destinationIndexPath: IndexPath)
    {
        let elem = savedConversions.remove(at: sourceIndexPath.row)
        savedConversions.insert(elem, at: destinationIndexPath.row)
    }
    

    执行
    caneditrowatinexpath
    数据源方法,如果表格处于编辑模式,则返回
    false
    ;如果表格未处于编辑模式,则返回
    true
    ,这样可以保持滑动操作,但使编辑按钮不执行任何操作。使用的代码:
    func tableView(tableView:UITableView,CaneditRowatingIndexPath indexPath:NSIndexPath)->Bool{if(tableView.editing==true){return false}else{return true}
    实际上这听起来很合理。好吧,那你怎么使用这个删除按钮呢?默认情况下它什么都不做,尽管我希望它调用tableView(\uTableView:UITableView,commit editingStyle:UITableViewCellEditingStyle,forRowAt indexPath:indexPath)对于editingStyle==.delete,我已经发现,将这些行放进去会阻止向左滑动手势显示删除按钮。
    override func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
        return .none
    }
    
    override func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool {
        return false
    }