ios - UITableView with SearchView makes new cells overlap old ones on search -


iam implementing searchview filter data in uitableview. iam able search successfully, issue when uitableview data gets filtered, old cells still exist , filtered ones overlap them giving me messy output. have cleared table source suggested answers on so, still not resolved problem.

here iam trying do:

filtercontroller

void searchfiler_textchanged(object sender, uisearchbartextchangedeventargs e) {

    if (!string.isnullorempty(e.searchtext))     {         pptable.source = null;         appdelegate.filteredlist = null;          pptable.reloaddata();         filteredmodellist = filter(dupes, e.searchtext);         madapter = new peopleplacessource(filteredmodellist, "");         pptable.source = madapter;         pptable.reloaddata();     }     else     {         pptable.source = null;         madapter = new peopleplacessource(dupes, "");         searchfiler.textchanged += searchfiler_textchanged;         madapter.tablerowselected += madapter_tablerowselected;         pptable.source = madapter;         pptable.reloaddata();     } } 

peopleplacessource

public override uitableviewcell getcell(uitableview tableview, foundation.nsindexpath indexpath)         {               cell = tableview.dequeuereusablecell("peopleplacescell_cell") peopleplacescell ?? peopleplacescell.create(); sublist = userlist.elementat(indexpath.row);                cell.updatepeopleplacescell(sublist);              return cell;          } 

peopleplacescell

 internal void updatepeopleplacescell(system.linq.igrouping<string, models.employeemodel> sublist)     {         var yposition =15;         var xposition = 10;          var imgdefault = new uiimageview();         imgdefault.frame = new coregraphics.cgrect(10, viewparent.frame.y, 60,60);         imgdefault.image = uiimage.fromfile("ic_appicon.png");         calayer profileimagecircle = imgdefault.layer;         profileimagecircle.cornerradius = 28;         profileimagecircle.borderwidth = 2;         profileimagecircle.bordercolor = new coregraphics.cgcolor(211, 34, 41);         profileimagecircle.maskstobounds = true;         imgdefault.clipstobounds = true;         viewparent.addsubview(imgdefault);           var labelusername = new uilabel();         labelusername.frame = new coregraphics.cgrect(0, 0, viewcontainer.frame.width, 30);         labelusername.textcolor = uicolor.fromrgb(211, 34, 41);         labelusername.text = sublist.key ;         labelusername.clipstobounds = true;          labelusername.font = uifont.boldsystemfontofsize(17);         viewcontainer.addsubview(labelusername);            var mlist = sublist.take(5);         foreach (var employeemodel in mlist)         {             var labelplace = new uilabel();             labelplace.frame = new coregraphics.cgrect(0, yposition, viewcontainer.frame.width, 50);              if (employeemodel.place.contains(","))             {                 labelplace.text = employeemodel.place.substring(0, employeemodel.place.indexof(","));             }             else             {                 labelplace.text = employeemodel.place;             }             labelplace.font = uifont.fromname(labelplace.font.name, 12f);             labelusername.sizetofit();                 labelplace.clipstobounds = true;             viewcontainer.addsubview(labelplace);               yposition += 15;             }     } 

how can solve this? appreciated

do have same problem after scroll? cells reused, don't see code removing added subviews. try remove subviews added, before reusing cells.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -