_mainTableView.allowsMultipleSelectionDuringEditing = YES;
self.selectionStyle = UITableViewCellSelectionStyleDefault;
UIView *view = [[UIView alloc] init]; view.backgroundColor = UIColorFromRGB(0xF6F6F6); self.selectedBackgroundView = view;
[self.viewModel.rightViewModel.clickSubject subscribeNext:^(id x) {
@strongify(self);
if (self.mainTableView.editing) {
self.viewModel.rightViewModel.title = @"编辑";
[UIView animateWithDuration:0.5 animations:^{
[self.mainTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
@strongify(self);
make.edges.equalTo(self);
}];
}];
} else {
self.viewModel.rightViewModel.title = @"确定";
[UIView animateWithDuration:0.5 animations:^{
[self.mainTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
@strongify(self);
make.left.right.top.equalTo(self);
make.bottom.equalTo(-50);
}];
}];
}
[self.mainTableView setEditing:!self.mainTableView.editing animated:YES];
}];
[[[self.deleteBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
@strongify(self);
NSMutableArray *deleteArray = [NSMutableArray array];
for (NSIndexPath *indexPath in self.mainTableView.indexPathsForSelectedRows) {
[deleteArray addObject:self.viewModel.dataArray[indexPath.row]];
}
NSMutableArray *currentArray = self.viewModel.dataArray;
[currentArray removeObjectsInArray:deleteArray];
self.viewModel.dataArray = currentArray;
[self.mainTableView deleteRowsAtIndexPaths:self.mainTableView.indexPathsForSelectedRows withRowAnimation:UITableViewRowAnimationLeft];//删除对应数据的cell
dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC));
dispatch_after(delayTime, dispatch_get_main_queue(), ^{
@strongify(self);
[self.mainTableView reloadData];
});
}];
#pragma mark - delete
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"删除此经验";
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
[self.viewModel.deleteCommand execute:indexPath];
}
[[[self.deleteBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(id x) {
[viewModel.deleteCommand execute:nil];
}];
[[self.viewModel.deleteSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSIndexPath *indexPath) {
@strongify(self);
if (self.viewModel.dataArray.count > indexPath.row) {
[self.viewModel.dataArray removeObjectAtIndex:indexPath.row]; //删除数组里的数据
[self.mainTableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];//删除对应数据的cell
dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC));
dispatch_after(delayTime, dispatch_get_main_queue(), ^{
@strongify(self);
[self.mainTableView reloadData];
});
}
}];
self.tableView.allowsSelection = NO;
self.tableView.allowsMultipleSelection = YES;
self.tableView.allowsSelectionDuringEditing = NO;
self.tableView.allowsMultipleSelectionDuringEditing = YES;
[self.tableView indexPathsForSelectedRows]
[self.tableView indexPathsForVisibleRows];
cell.selectedBackgroundView.backgroundColor
cell.selectedBackgroundView
cell.textLabel.highlightedTextColor
[theTableView setSeparatorColor:[UIColor xxxx ]];
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//消除cell选择痕迹
[self performSelector:@selector(deselect) withObject:nil afterDelay:0.5f];
}
- (void)deselect {
[self.tableview deselectRowAtIndexPath:[self.tableview indexPathForSelectedRow] animated:YES];
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有