没更新9之前左滑删除好好的!更新后突然就出问题了,可以左滑显示删除按钮,但是点击删除按钮的时候就是不执行commitEditingStyle这个代理方法 ;
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
//返回删除按钮的标题
- (nullable NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"删除";
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete)
{
//删除操作
}
}
改用下面这个代理方法时不走删除操作。
-(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewRowAction *deleteRoWAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
// 删除操作
NSLog(@"==========删除操作============");
}];
return @[deleteRoWAction];
}
我的实现左滑删除的方法没有错,我有新建一个工程进行测试,可以实现删除的,但是在现在这个程序中就是找不到哪里冲突了,竟然是所有的左滑删除都不执行删除操作的代理!我添加左滑删除的table 有的是系统自己的cell 有的是我自定义的xib