Due to the network reasons do not see the effect, my left is a large classification of the cell, to the right is a small classification of the cell, small classification of the support of multiple selection and then passed to the previous interface, where the value can be used block
In fact, it is the cell to add a gesture, use this gesture to determine whether the selected state, when clicking on the cell, the data above the cell (I defined a variable array selectarray, this array is initialized when the page starts to load data, With the array initialization, the number of initialization is the number of TableView of the parent class, in the definition of an int row of data, as long as the click of the parent class TableView to record the cell, if you do not log other subclasses TableView the same location will also appear selected) when clicked, If there is no data on the current cell in the Selectarray, append, if any, delete, Indexpath is the cell inside the record which line, such as (0-0)
I've been working in a. m file.
int lastselectbigtableviewrow;
@property (Nonatomic,strong) nsmutablearray * Bigdataarray;
@property (Nonatomic,strong) nsmutablearray * Smalldataarray;
@property (Nonatomic,strong) nsmutablearray * Selectarray;
-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{
UITableViewCell * cell = [TableView dequeuereusablecellwithidentifier:@ "ID"];
if (cell = = nil) {
cell = [[UITableViewCell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:@ "ID"];
}
Cell.selectionstyle = Uitableviewcellselectionstylenone;
Cell.textLabel.text = [Self.smalldataarray[indexpath.row] objectforkey:@ "Category_name"];
Cell.textLabel.textAlignment = Nstextalignmentleft;
Cell.textLabel.textColor = [Uicolor Graycolor];
if ([[[Self.selectarray Objectatindex:lastselectbigtableviewrow] Containsobject:indexpath]) {
Cell.imageView.image = [UIImage imagenamed:@ "Cur-photo-blue.png"];
}
Else
{
Cell.imageView.image = [UIImage imagenamed:@ "Cur.png"];
}
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (handlechecking:)] ;
[Cell.imageview Addgesturerecognizer:tap];
cell.imageView.userInteractionEnabled = YES;
return cell;
}
}
return nil;
}
-(void) handlechecking: (UITapGestureRecognizer *) Taprecognizer {
Cgpoint taplocation = [Taprecognizer Locationinview:_subtableview];
Nsindexpath *tappedindexpath = [_subtableview indexpathforrowatpoint:taplocation];
if ([[[Self.selectarray Objectatindex:lastselectbigtableviewrow] Containsobject:tappedindexpath]) {
[[Self.selectarray Objectatindex:lastselectbigtableviewrow] removeobject:tappedindexpath];
}
else {
[[Self.selectarray Objectatindex:lastselectbigtableviewrow] addobject:tappedindexpath];
}
[_subtableview Reloadrowsatindexpaths:[nsarray Arraywithobject:tappedindexpath] WithRowAnimation: Uitableviewrowanimationfade];
}
This is a save button, I want to take the value on the Subview to the previous interface
-(void) saveclick{
Self.selectarray
nsmutablestring * str = [[Nsmutablestring alloc] init];
for (int i = 0; i < [Self.selectarray count]; i++) {
if ([[Self.selectarray objectatindex:i] count] > 0) {
[Str appendstring:[[self.bigdataarray objectatindex:i] objectforkey:@ "Category_name"];
for (int j = 0; J < [[Self.selectarray OBJECTATINDEX:I] count]; j + +) {
Nsindexpath * Path = [[Self.selectarray objectatindex:i] objectatindex:j];
Nsmutablearray * Temparray = [Self.bigdataarray[i] objectforkey:@ "items"];
Nsdictionary * dic = [temparray objectatindex:[path row]];
[Str appendstring:[dic objectforkey:@ "Category_name"];
[Str appendstring:@ ","];
}
}
}
if (Self.myblock) {
Self.myblock (str);
}
[Self.navigationcontroller Popviewcontrolleranimated:yes];
}
Reference: Http://stackoverflow.com/questions/3666629/how-to-add-checkboxes-to-uitableviewcell
UITableViewCell Adding a CheckBox multi-select