关于tableView多选删除的编辑设置
来源:互联网 发布:屏幕录像软件 编辑:程序博客网 时间:2024/04/29 22:30
-(void)editAction:(UIButton*)sender
{
[self.tableViewsetEditing:YESanimated:YES];
sender.selected=!sender.selected;
NSLog(@"%d",sender.selected);
[sender setTitle:sender.selected?@"完成":@"编辑"forState:UIControlStateNormal];
[_tableView reloadData];
if (sender.selected)
{
self.tableView.editing=YES;
if (self.tableView.editing==YES) {
}
[selfaddAllSelectView];
}
if (!sender.selected) {
self.tableView.editing=NO;
self.tableView.frame =CGRectMake(0,0, iPhoneWidth,iPhoneHeigt);
self.editView.hidden =YES;
}
}
// 设置tableView是否可以删除
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
return YES;
}
// 设置删除操作时候的标题
-(NSString*)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
return @"删除";
}
//问题2:某一行支持哪种编辑模式
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
returnUITableViewCellEditingStyleDelete;//|UITableViewCellEditingStyleInsert;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"%ld",(long)editingStyle);
if (editingStyle==UITableViewCellEditingStyleDelete)
{
[SVProgressHUDshow];
if (self.DeleteCollectionBlock)
{
self.DeleteCollectionBlock();
}
NSString *codeString=[NSStringstringWithFormat:@"%@-%@",UserID,KEY];//(md5(account-key))
NSString *code=[NSStringmd5:codeString];
// MD5加密
NSString *urlString=[NSStringstringWithFormat:、xxxxxxxxxxxxxxxxxxx];
NSMutableDictionary *params = [NSMutableDictionarydictionary];
params[@"user_id"] = UserID;
params[@"act"] = @"delete";
params[@"rec_id"] = [dataArray[indexPath.row]objectForKey:@"rec_id"];
[[UIApplicationsharedApplication]setNetworkActivityIndicatorVisible:NO];
NSLog(@"%@",urlString);
[WXNetworking WXBaseNetworkWithPOST:xxxxxx params:params success:^(id responseObject) {
// 删除成功后移除数据源并刷新tableView
[dataArray removeObjectAtIndex:indexPath.row];
[tableView endUpdates];
[tableView reloadData];
} failure:^(NSError *error) {
}];
}
if (editingStyle ==UITableViewCellEditingStyleInsert) {
NSIndexPath *newIP=[NSIndexPathindexPathForItem:dataArray.count-1inSection:0];
[tableView insertRowsAtIndexPaths:@[newIP]withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
for (UIView *viewin cell.subviews) {
if ([viewisKindOfClass:NSClassFromString(@"UITableViewCellEditControl")])
{
for (UIView *vVVin view.subviews) {
NSLog(@"%@",vVV);
[vVV removeFromSuperview];
}
WXButton* checkButton= [selfcheckBox:CGRectMakeE(0,0,47,110)];
NSLog(@"%ld",(long)indexPath.row);
NSInteger row=indexPath.row;
int ii=(int)row;
NSLog(@"%d",ii);
checkButton.hang=ii;
[checkButton addTarget:selfaction:@selector(checkButton:)forControlEvents:UIControlEventTouchUpInside];
for (NSDictionary *temDict1in _selectArray)
{
if (dataArray[indexPath.row] == temDict1) {
checkButton.selected = YES;
}else{
}
}
[view addSubview:checkButton];
}
}
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
cell.preservesSuperviewLayoutMargins =NO;
}
// 多选时选中取消的操作
// 自定义的选中按钮 对选中按钮的勾选做对删除分组的操作
-(void)checkButton:(WXButton*)sender{
sender.selected=!sender.selected;
if (sender.selected==YES)
{
model = self.modelArray[sender.hang];
model.isSelect =YES;
[_selectArray addObject:dataArray[sender.hang]];
}
if (sender.selected ==NO)
{
//遍历删除数组 对所勾选的商品做出操作 _selectArray是要删除tableViewcell的数组 遍历对比选中的数组 tempArray 的使用是因为一个数组不能同事在两个线程做操作。
NSMutableArray *tempArray = [NSMutableArrayarrayWithArray:_selectArray];
for (NSDictionary *tempDicin _selectArray)
{
if (tempDic == dataArray[sender.hang])
{
[tempArray removeObject:tempDic];
}
_selectArray = tempArray;
}
}
}
- 关于tableView多选删除的编辑设置
- Swift 关于tableView的多选和删除
- CYC- tableView的删除编辑移动
- 编辑删除收藏在tableView的内容
- tableView 如何设置仅某一行cell可以编辑删除
- 编辑tableView 多选删除 全选删除 修改系统默认删除图片
- 设置TableView可编辑
- 关于设置tableView的背景图片
- 关于tableview 编辑下多选择处理
- tableview 多选删除
- TableView的多选删除,搜索
- TableView中的编辑删除功能
- tableView的编辑删除插入操作和UIAlertController的使用
- iOS中tableview 中编辑,删除与多选中的问题(一)
- tableview中编辑,删除与多选中的问题(二)
- 编辑表格@tableView实现增加、删除、移动的操作
- iOS tableView编辑删除(单选 多选)
- tableView编辑模式下删除多个cell
- 对深拷贝与浅拷贝的再次理解
- 用jdom创建中文的xml文件
- AIDL的简单Demo
- c#使用多线程的几种方式示例详解
- ServletConfig与ServletContext区别
- 关于tableView多选删除的编辑设置
- 欢迎使用CSDN-markdown编辑器
- 编写一个掷骰子100次的程序,打出各种点数的出现次数
- stm32F429,emWin,屏幕做XY轴翻转,以及随之出现的闪屏问题
- RxJava详解
- web开发各种路径的获取
- 大数据常见面试题汇总(一)
- 用JavaScript玩转游戏物理(一)运动学模拟与粒子系统
- 在windows电脑上做一个网络位置驱动