UITableView侧滑删除

//设置编辑模式为删除

- (UITableViewCellEditingStyle)tableView:(UITableView*)tableView editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath{

returnUITableViewCellEditingStyleDelete;

}

//设置删除按钮的文字标题

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

return@"删除";

}

//点击删除按钮后进行数据处理

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

if(editingStyle ==UITableViewCellEditingStyleDelete) {//判断tyle 是否是删除

//获取需要删除的哪一行数据

SweepsDatamodel1*model =self.dataSource[indexPath.row];

//这是我自己请求的接口(要换成你自己的)

[selfinitDataWithRemoveSweepsStakesRecordByRecordId:model.iduserId:[[UserDefaultsobjectForKey:@"userID"]integerValue]];

//在数组里面删除self.dataSource是我的数据源

[self.dataSourceremoveObjectAtIndex:indexPath.row];

//刷新表

[_myWiningRecordTableViewreloadData];

}

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容