代码之家  ›  专栏  ›  技术社区  ›  arachide

如何禁用UITableView中特定行的删除操作?

  •  15
  • arachide  · 技术社区  · 14 年前

    我知道如何使用 setEditing: 启用UITableView的编辑模式。

    有可能吗?

    谢谢,

    interdev公司

    4 回复  |  直到 13 年前
        1
  •  33
  •   kennytm    14 年前

    实施 the -tableView:canEditRowAtIndexPath: method 在数据源中。返回 NO 为了那些排。

        2
  •  10
  •   Community CDub    8 年前

    Is there any way to hide "-" (Delete) button while editing UITableView

    如果您不想阅读文章,要点就在您不想删除但想允许移动行的行上:将行的编辑样式设置为UITableViewCellEditingStyleNone

    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
        return UITableViewCellEditingStyleNone; 
    }
    
        3
  •  9
  •   Youyou    13 年前

    使用CanEditRowatingIndexPath将不允许该行与分组样式中的其他单元格对齐。看起来很糟糕。

    UITableViewCellEditingStyleNone ,对于不希望显示编辑控件(减号/加号按钮)的行,请将其放入

    (UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{}
    
        4
  •  2
  •   Sethuraghavan    9 年前

    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    
        if(indexPath.row==0)
        {
            return NO;
        }
        return YES;
    }