2016-03-10 block 容联中的
1:
- (IBAction)ImageBtnAction:(id)sender {
if (!self.ImageBtn.selected) {
selecImageBlocks(self.PhoneStr);
}
else{
removeImageBlocks(self.PhoneStr);
}
self.ImageBtn.selected =!self.ImageBtn.selected;
}
2:
void(^selecImageBlocks)(NSString * str); // 添加电话号码
void(^removeImageBlocks)(NSString * str); // 删除电话号码
3:
-(void)makecellWithBlocks:(void(^)(NSString * str))Blocks;
-(void)makeRemoveImageBlocks:(void(^)(NSString * str))Blocks;
4:
-(void)makecellWithBlocks:(void (^)(NSString *))Blocks{
selecImageBlocks =[Blocks copy];
}
-(void)makeRemoveImageBlocks:(void (^)(NSString *))Blocks{
removeImageBlocks =[Blocks copy];
}
5:
[cell makecellWithBlocks:^(NSString *str) {
[mut replaceObjectAtIndex:indexPath.row withObject:@"1"];
[selectpersontitle addObject:cell.Textlabel.text];
[selectPsedonUuid addObject:cell.UuidStr];
[sureButton setTitle:[NSString stringWithFormat:@"确定(%lu)",(unsigned long)[selectpersontitle count ]] forState:UIControlStateNormal];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:sureButton];
[_tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[SeletPersonList addObject:str];
}];
[cell makeRemoveImageBlocks:^(NSString *str) {
if ([SeletPersonList containsObject:str]) {
[mut replaceObjectAtIndex:indexPath.row withObject:@"0"];
[SeletPersonList removeObject:str];
[selectpersontitle removeObject:cell.Textlabel.text];
[selectPsedonUuid removeObject:cell.UuidStr];
[_tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}
[sureButton setTitle:[NSString stringWithFormat:@"确定(%lu)",(unsigned long)[selectpersontitle count ]] forState:UIControlStateNormal];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:sureButton];
}];