ios - Reloading data in tableView for invisible sections -
then json update reload tableview, have tableview collectionview within , have little lag in visible cell @ moment of reload. want reload invisible cell of tableview. there no 'visiblesections' method 'visiblecells'.
i visible sections
nsarray *visiblesections = [[self.tableview indexpathsforvisiblerows]valueforkey:@"section"]; not want sections, remove visiblesections , reload new array. can not find way sections. how can it?
you utilize 1 of these methods:
- (void)reloadrowsatindexpaths:withrowanimation: - (void)reloadsections:withrowanimation: edit
when seek indexpaths of invisible cells, seek this:
nsmutablearray *invisiblecells = [nsmutablearray array]; (int = 0; < [tabstableview numberofsections]; i++) { (int n = 0; n < [tabstableview numberofrowsinsection:i]; n++) { (nsindexpath *indexpath in [tabstableview indexpathsforvisiblerows]) { if ([indexpath section] == && [indexpath row] == n) { goto nextiteration; } } [invisiblecells addobject:[nsindexpath indexpathforrow:n insection:i]]; nextiteration:; } } more of import why that?! due uitableviewcells reused, won't updatable. when cell "invisible", changes content , used @ different position within visible cells. how uitableview works.
you (also currently) utilize method set content of cell:
- (void)tableview:tableview cellforrowatindexpath:indexpath { uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:_cellid]; if (!cell) { cell = (uitableviewcell *)[[[nsbundle mainbundle] loadnibnamed:@"celltemplate" owner:nil options:nil] objectatindex:0]; } // configure cell content here } when cell get's reused, method gets called , create cell if uitableview not reuse invisible cell. if does, alter content.
so there no need reload invisible cells , it's impossible. from docs:
return value
an object representing cell of table or nil if cell not visible or indexpath out of range.
ios objective-c uitableview
No comments:
Post a Comment