iphone - problem with table view grouped table view -


tableview problem: using 3 uilable displaying productname, description , image. data displayed when scrolling table labels filled text actual text.. how can handle this? code:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath; {     static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];     if (cell == nil)      {         cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease];      }   uiimageview *imageview = [[uiimageview alloc]initwithframe:cgrectmake(2, 2, 41, 41)];     [cell setaccessorytype:uitableviewcellaccessorydisclosureindicator];      nsdictionary *adict1   = [[nsdictionary alloc]init];     adict1 = [tabledata objectatindex:indexpath.row];      nsstring *prdstus = [adict1 objectforkey:@"productstatus"];     nslog(@"product status %@ ",prdstus);     if ([prdstus isequaltostring:@"orange"]) {         [imageview setimage:[uiimage imagenamed:@"yellow.png"]];     }     if ([prdstus isequaltostring:@"green"]) {         [imageview setimage:[uiimage imagenamed:@"green.png"]];     }     if ([prdstus isequaltostring:@"red"]) {         [imageview setimage:[uiimage imagenamed:@"red.png"]];     }      uilabel *label2 = [[uilabel alloc]initwithframe:cgrectmake(46, 0, 220, 12) ];     label2.font = [uifont systemfontofsize:12];     label2.text = @"";     if (indexpath.row <[tabledata count]) {         label2.text = [adict1 objectforkey:@"productname"];     }      [cell addsubview:label2];       [cell addsubview:imageview];     label2.backgroundcolor =[uicolor clearcolor];     uilabel *label3 = [[uilabel alloc]initwithframe:cgrectmake(46, 13, 220, 30) ];     label3.font = [uifont systemfontofsize:10];     label3.text = @"";     label3.text = [adict1 objectforkey:@"productdescription"];      [cell addsubview:label3];       return cell;  } 

please tell me how avoid this..

grouped table view.

here facing same problem. using 4 section 1st , 3rd sections 1 row each, 2nd sec 3 rows, 4th sec 5

when configure text first section label displayed on 4th , 3rd section data displayed on 4th section. code

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath; {     static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];     if (cell == nil)       {          cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease];      }      cell.userinteractionenabled =no;  if (indexpath.section == 0)       {         uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(12, 2, 294, 40) ];         label.backgroundcolor = [uicolor clearcolor];         nsdictionary *adict1   = [[nsdictionary alloc]init];         adict1 = [detailsarray objectatindex:0];          label.text=@"";         label.text =[adict1 objectforkey:@"productname"];         label.numberoflines = 2;         label.linebreakmode = uilinebreakmodewordwrap;         [cell addsubview:label];         [label release];       //  [cell addsubview:imgview1];     //  [imgview1 release];      }      if (indexpath.section ==1 ) {              if (indexpath.row == 0)          {             imgview = [[uiimageview alloc]initwithframe:cgrectmake(255,2 , 46, 46)];             [cell addsubview:imgview];             [imgview release];             cell.textlabel.text = @"actual halal rating";              nsdictionary *adict1   = [[nsdictionary alloc]init];             adict1 = [detailsarray objectatindex:0];              nsstring *statstr=[[nsstring alloc] init];             statstr = [adict1 objectforkey:@"producthalalstatus"];             nslog(@"status %@",statstr);              imgview1 = [[uiimageview alloc]initwithframe:cgrectmake(255,2 , 20, 20)];               if ([statstr isequaltostring:@"red"]) {                  [imgview1 setimage:[uiimage imagenamed:@"red.png"]];              }             if ([statstr isequaltostring:@"orange"] ) {                  [imgview1 setimage:[uiimage imagenamed:@"yellow.png"]];              }             if ([statstr isequaltostring:@"green"]) {                   [imgview1 setimage:[uiimage imagenamed:@"green.png"]];              }             [cell addsubview:imgview1];             [imgview1 release];          }          if (indexpath.row == 1) {             cell.textlabel.text = @"halal (permisible)";             [imgview setimage:[uiimage imagenamed:@"green.png"]];         }          if (indexpath.row == 2) {             cell.textlabel.text = @"masbooh (doubtful)";             [imgview setimage:[uiimage imagenamed:@"yellow.png"]];         }          if (indexpath.row == 3) {             cell.textlabel.text = @"haram (not permisible)";             [imgview setimage:[uiimage imagenamed:@"red.png"]];         }      }        if (indexpath.section == 2) {           nsdictionary *adict2   = [[nsdictionary alloc]init];         adict2 = [detailsarray objectatindex:0];      // nsarray *ingrarr =[adict2 objectforkey:@"ingredientinfo1"];          textview1 =[[uitextview alloc]initwithframe:cgrectmake(12, 2, 294, 96)];         //textview1.text = ingrstr;         textview1.editable =no;         [textview1 setfont:[uifont systemfontofsize:15]];         [cell addsubview:textview1];         [textview1 release];      }       if (indexpath.section == 3) {       }     return cell; } 

remove line, code ....

if (cell == nil) { cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease];   

and add following line

cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease] 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -