滑动以删除UITableView问题中的选项

Raj*_*Raj 6 iphone objective-c uitableview ios

我想在我的项目中使用"轻扫删除"选项.

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{

    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        NSDictionary *userData = [_contactsArray objectAtIndex:indexPath.row];
        NSLog(@"delete row %@",userData);
    }
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{

    return YES;
}
Run Code Online (Sandbox Code Playgroud)

我正在使用此代码,但它提供了我不想要的以下输出.在此输入图像描述

我不希望左侧减号在单元格上.我只想要滑动并显示删除按钮.我在之前的项目中使用的代码相同,但工作正常(即只滑动显示删除按钮,左侧没有减号)

请帮我解决这个问题.

hgw*_*tle 9

您正在覆盖"滑动删除"功能的正确委托方法.关于减号:

像这样隐藏减号:

self.yourTableView.editing = NO;
//or simply remove this line of code altogether because this property is NO by default
Run Code Online (Sandbox Code Playgroud)

像这样显示减号:

self.yourTableView.editing = YES;
Run Code Online (Sandbox Code Playgroud)