iphone - Ui label value is overlapping in table view after updating -


- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {    // nsstring *cellidentifier = [nsstring stringwithformat:@"cell%d",indexpath.row];       static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];      if (cell == nil)     {         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier];         }     //clear cells subview before drawing cell     for(uiview *view in cell.contentview.subviews)     {         if ([view iskindofclass:[uiview class]])         {             [view removefromsuperview];         }     }      if (arrplaceid.count>0)     {           lblplacename=[[uilabel alloc]initwithframe:cgrectmake(30, 3, 300, 20)];         lblplacename.font=[uifont fontwithname:@"arial" size:15];         lblplacename.textcolor=[uicolor whitecolor];          lblplacename.backgroundcolor=[uicolor clearcolor];          lbladdress=[[uilabel alloc]initwithframe:cgrectmake(30, 20, 300, 18)];         lbladdress.font=[uifont fontwithname:@"arial" size:15];         lbladdress.textcolor=[uicolor whitecolor];          lbladdress.backgroundcolor=[uicolor clearcolor];           lblplacename.text=[arrplacename objectatindex:indexpath.row];         lbladdress.text=[arrplaceaddress objectatindex:indexpath.row];           [cell addsubview:lblplacename];         [cell addsubview:lbladdress];     }        return cell; } 

add method

for(id obj in cell.contentview.subviews)     {         if([obj iskindofclass:[uilabel class]])         {             [obj removefromsuperview];         }     } 

instead of

for(uiview *view in cell.contentview.subviews)     {         if ([view iskindofclass:[uiview class]])         {             [view removefromsuperview];         }     } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -