ios - how to load two tableview in same view controller with cell for index row? -


i facing 1 module consists load 2 different uitableview in same uiviewcontroller know doing mistake, problem cell row atindexpath in table view method. getting 1 uitableview in uiviewcontroller secondviewcontroller not return values in cell.

here sample code ur reference:

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { if (tableview==table) {      return [self.arrydata count]; } else return [tblarr count]; nslog(@"tabecount==>%lu",(unsigned long)tblarr.count);  }  - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { return 55; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath  { static nsstring *cellidentifier  = @"cell"; static nsstring *cellidentifier1 = @"cell";         dequeuereusablecellwithidentifier:cellidentifier]; uitableviewcell *cell; mobileplandetailscelltableviewcell *plan_cell;  if (tableview==table) {     cell = [self.table dequeuereusablecellwithidentifier:cellidentifier];     if (cell == nil) {         cell = [[uitableviewcell alloc]                 initwithstyle:uitableviewcellstyledefault                 reuseidentifier:cellidentifier];     }     cell.textlabel.font = [uifont systemfontofsize:12];     cell.textlabel.text = [self.arrydata objectatindex:indexpath.row];   }return cell;  if (tableview==plantable) {      plan_cell =  [self.plantable dequeuereusablecellwithidentifier:cellidentifier1];     if (plan_cell == nil) {         nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"mobileplandetailscelltableviewcell" owner:self options:nil];         plan_cell = [nib objectatindex:0];     }      plan_cell.label.text = [[tblarr objectatindex:indexpath.row] objectforkey:@"answer1"];     plan_cell.label2.text = [[tblarr objectatindex:indexpath.row]objectforkey:@"answer2"];     plan_cell.label3.text = [[tblarr objectatindex:indexpath.row]objectforkey:@"answer3"];     plan_cell.label4.text = [[tblarr objectatindex:indexpath.row]objectforkey:@"answer4"];   }     return plan_cell; }   - (void) tableview:(uitableview *)tableview willdisplaycell:(uitableviewcell *)cell forrowatindexpath:(nsindexpath *)indexpath { [tableview setbackgroundcolor:[uicolor whitecolor]]; [cell setbackgroundcolor:[uicolor whitecolor]];   } 

you made small mistake change return cell in inside method

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {    static nsstring *cellidentifier  = @"cell"; if (tableview==table) {   uitableviewcell *cell = [self.table dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) {     cell = [[uitableviewcell alloc]             initwithstyle:uitableviewcellstyledefault             reuseidentifier:cellidentifier]; } cell.textlabel.font = [uifont systemfontofsize:12]; cell.textlabel.text = [self.arrydata objectatindex:indexpath.row];  return cell;  } else {      mobileplandetailscelltableviewcell *plan_cell =  [self.plantable dequeuereusablecellwithidentifier: cellidentifier]; if (plan_cell == nil) {     nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"mobileplandetailscelltableviewcell" owner:self options:nil];     plan_cell = [nib objectatindex:0]; }  plan_cell.label.text = [[tblarr objectatindex:indexpath.row] objectforkey:@"answer1"]; plan_cell.label2.text = [[tblarr objectatindex:indexpath.row]objectforkey:@"answer2"]; plan_cell.label3.text = [[tblarr objectatindex:indexpath.row]objectforkey:@"answer3"]; plan_cell.label4.text = [[tblarr objectatindex:indexpath.row]objectforkey:@"answer4"];    return plan_cell;  }  } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -