快速解决侧滑删除按钮的示例

快速解决侧滑删除按钮的示例

tableView

快速解决侧滑删除按钮的示例_第1张图片
删除按钮示例.gif

懒加载数据

-(NSMutableArray *)array_Contast{
if (!_array_Contast) {
    
    _array_Contast = [NSMutableArray new];
}

return  _array_Contast;
}

设置tableView为可编辑状态

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

[self.array_Contast removeObjectAtIndex:indexPath.row];

删除某一行

[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

记住删除后,一定要归档一次

[NSKeyedArchiver archiveRootObject:self.array_Contast toFile:kFilePath];    
}

-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{

return @"删除";
}

你可能感兴趣的:(快速解决侧滑删除按钮的示例)