Almost, take the data source, say, n sections, each section inside the cell number is not fixed, the data source content is not necessarily, resulting in the cell form will be different
Fetch from the data source if you write if else, or switch is not satisfied, perhaps Swift is more bull, not mentioning
It's just that you want to calculate the index value of a unique data source array corresponding to a different cell based on the resource you have
Write bad, if there is better hope to share a bit, learn from each other! (Dozens of scetion should not be surprised by apparent efficiency)
Not much to say on the code:
-(Nsarray *) arraytitle
{
if (!_arraytitle) {
_arraytitle = @[@ "Don't let him (her) See my family tree", @ "Don't let him (her) see my News", @ "Don't look at his (her) dynamic"];
}
Return @[@ "Don't let him (her) See my family tree", @ "Don't let him (her) see my News", @ "Don't look at his (her) dynamic"];
}
-(Nsarray *) arrayvcforjump
{
if (!_arrayvcforjump) {
_arrayvcforjump = @[[mhnotshowfamilytreecontroller Class],[mhnotshoweventtoothercontroller class],[ Mhnotseeothereventcontroller class]];
}
return _arrayvcforjump = @[[mhnotshowfamilytreecontroller Class],[mhnotshoweventtoothercontroller class],[ Mhnotseeothereventcontroller class]];
}
#pragma mark calculates the index value of the current array, which is guaranteed not to repeat because of the Indexpath
-(Nsinteger) Getcurrentindexfordataarray: (nsindexpath*) Indexpath TableView: (UITableView *) TableView
{
//****************
self.numofindexpromate = 0;
for (Nsinteger i=0; i<indexpath.section; i++) {
Self.numofindexpromate + = [TableView numberofrowsinsection:i];
}
//***************
return self.numofindexpromate;
}
-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath
{
Cell rarely temporarily does not consider reuse
Mhprivacytableviewcell * cell = [[Mhprivacytableviewcell alloc]init];
Cell.textLabel.textColor = Mheventcelltitlecolor;
Cell.textLabel.text = self.arraytitle[indexpath.row+indexpath.section];//The value here is not unique in more than one section and should be noted later
Nsinteger num = [self getcurrentindexfordataarray:indexpath tableview:tableview];
Cell.textLabel.text = Self.arraytitle[num+indexpath.row];
return cell;
}
#pragma mark-click the cell jump Agent
-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath
{
Nsinteger num = [self getcurrentindexfordataarray:indexpath tableview:tableview];
Class strvcname = Self.arrayvcforjump[indexpath.row+num];
Class strvcname = self.arrayvcforjump[indexpath.row+indexpath.section];
NSString * strClassName = Nsstringfromclass (strvcname);
if ([strClassName iscontainonestr:@ "Controller"]) {
Uiviewcontroller * VC = [[Strvcname alloc]init];
[Self.navigationcontroller PUSHVIEWCONTROLLER:VC Animated:yes];
}
Else
{
Return
}
}
TableView lazy Jump way, load data source way