iphone - How to display different element from different array in different section in single table view? -



iphone - How to display different element from different array in different section in single table view? -

i have table 3 sections, 3 sections have different number of rows. cell values should populate different array's. how should find out section in method cellforrowatindexpath:???

please help!!!

code: - (nsinteger)tableview:(uitableview *)tv numberofrowsinsection:(nsinteger)section { currentsection = section; int number = 0; switch (section) { case 0: number = self.basic.count; break; case 1: number = allsectors.count; break; case 2: number = 1; break; default: number = 0; break; } homecoming number; } - (uitableviewcell *)tableview:(uitableview *)tv cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tv dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstylevalue1 reuseidentifier:cellidentifier]autorelease]; } cell.accessorytype = uitableviewcellaccessorydisclosureindicator; cgfloat fontsize = [uifont systemfontsize]; cgfloat smallfontsize = [uifont smallsystemfontsize]; switch (indexpath.section) { case 0: cell.textlabel.text = [self.basic objectatindex:indexpath.row]; break; case 1: cell.textlabel.text = [self.allsectors objectatindex:indexpath.row]; break; case 2: cell.textlabel.text = @"none"; break; default: break; } homecoming cell; }

just utilize indexpath.section table section, , indexpath.row row in section. these properties defined in category nsindexpath (uikitadditions).

iphone objective-c uitableview

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -