关于tableview 编辑下多选择处理
来源:互联网 发布:数据化分析 编辑:程序博客网 时间:2024/05/16 15:02
1.设置可以多选择(并且设置tintColor 可以改变右侧 符号颜色)
self.tableView.allowsMultipleSelectionDuringEditing = YES;
self.tableView.tintColor =MAIN_THEME_GREEN_COLOR;
效果图:
2.定义下面修改状态的toolView
UIView *spliter = [UIViewnew];
spliter.backgroundColor =NORMAL_SPLITER_GREY;
[self.toolViewaddSubview:spliter];
[spliter mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.toolView);
make.height.mas_equalTo(0.5);
make.left.mas_equalTo(0);
make.top.mas_equalTo(0);
}];
self.changeSignBtn = [UIButtonnew];
self.changeSignBtn.titleLabel.font = BIG_FONT;
[self.changeSignBtnsetTitle:@"签到"forState:UIControlStateNormal];
[self.changeSignBtnsetTitleColor:MAIN_THEME_GREEN_COLORforState:UIControlStateNormal];
[self.changeSignBtnaddTarget:selfaction:@selector(batchChange:)forControlEvents:UIControlEventTouchUpInside];
[self.toolViewaddSubview:self.changeSignBtn];
.....
self.changeLateBtn = [UIButtonnew];
self.changeLateBtn.titleLabel.font = BIG_FONT;
[self.changeLateBtnsetTitle:@"迟到"forState:UIControlStateNormal];
[self.changeLateBtnsetTitleColor:MAIN_THEME_GREEN_COLORforState:UIControlStateNormal];
[self.changeLateBtnaddTarget:selfaction:@selector(batchChange:)forControlEvents:UIControlEventTouchUpInside];
[self.toolViewaddSubview:self.changeLateBtn];
.....
self.changeEarlyBtn = [UIButtonnew];
self.changeEarlyBtn.titleLabel.font = BIG_FONT;
[self.changeEarlyBtnsetTitle:@"早退"forState:UIControlStateNormal];
[self.changeEarlyBtnsetTitleColor:MAIN_THEME_GREEN_COLORforState:UIControlStateNormal];
[self.changeEarlyBtnaddTarget:selfaction:@selector(batchChange:)forControlEvents:UIControlEventTouchUpInside];
[self.toolViewaddSubview:self.changeEarlyBtn];
.....
self.changeUnsignBtn = [UIButtonnew];
self.changeUnsignBtn.titleLabel.font = BIG_FONT;
[self.changeUnsignBtnsetTitle:@"未签到"forState:UIControlStateNormal];
[self.changeUnsignBtnsetTitleColor:MAIN_THEME_GREEN_COLORforState:UIControlStateNormal];
......
3.右键编辑状态事件并且给toolview添加动画
-(void)showToolBar:(id)sender{
if (self.tableView.isEditing) {
[self.navigationItem.rightBarButtonItemsetTitle:@"编辑"];
[self.tableViewsetEditing:NOanimated:YES];
[UIViewbeginAnimations:nilcontext:nil];
[UIViewsetAnimationDuration:0.3];
[self.toolViewmas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_bottom);
}];
[self.viewlayoutIfNeeded];
[UIViewcommitAnimations];
self.selectedStatisticArray = [NSMutableArray<TchStdSignDetail*>new];
}else{
[self.navigationItem.rightBarButtonItemsetTitle:@"完成"];
[self.tableViewsetEditing:YESanimated:YES];
[UIViewbeginAnimations:nilcontext:nil];
[UIViewsetAnimationDuration:0.3];
[self.toolViewmas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_bottom).offset(-40);
}];
[self.viewlayoutIfNeeded];
[UIViewcommitAnimations];
self.selectedStatisticArray = [NSMutableArray<TchStdSignDetail*>new];
}
}
4.勾选添加删除的逻辑
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (tableView.editing) {
.......省略.......(statistic 是Model数据)
if([self.selectedStatisticArraycontainsObject:statistic]){
[self.selectedStatisticArrayremoveObject:statistic];
}else{
[self.selectedStatisticArrayaddObject:statistic];
}
}else{
[tableView deselectRowAtIndexPath:indexPathanimated:NO];
}
}
- 关于tableview 编辑下多选择处理
- 关于tableView多选删除的编辑设置
- tableView编辑模式下删除多个cell
- tableView编辑模式下删除多个cell
- TableView 编辑时,底部线的处理
- iOS-TableView编辑(多行编辑)
- TableView编辑
- TableView编辑
- tableview 编辑状态下,UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert 多选的时候,替换圆圈图片
- ios tableView编辑模式下cell中创建多个功能
- tableview 编辑状态下,UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert 多选的时候,替换圆圈图片
- tableview 编辑状态下,UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert 多选的时候,替换圆圈图片
- 可编辑的TableView
- 设置TableView可编辑
- tableview 编辑整理
- tableView选中状态编辑
- tableView的编辑模式
- tableView - 编辑模式
- RMQ感想
- 数据流重定向小总结
- javaweb学习总结(二十三)——jsp自定义标签开发入门
- Arithmetic 正整数的四则运算
- 多校训练-Bubble Sort(树状数组+离散化)
- 关于tableview 编辑下多选择处理
- HDU 3038 How Many Answers Are Wrong
- mac brew 安装使用
- 【指导】SonarQube 部署说明
- HDU 1025 Constructing Roads In JGShining's Kingdom
- web 开发一个能进行人员管理(查询,删除,添加)的应用
- //切割字符串
- vector的push_back
- 谈谈C里面的指针之二【指针的加减法】