ios - UITableView cell's seperators disappear when selected -
when select uitableviewcell , start scrolling point cells disappear screen, seperators on cells disappear once reappear on screen.
delegate:
- (void) tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { [self.tableview selectrowatindexpath:indexpath animated:no scrollposition:uitableviewscrollpositionnone]; uitableviewcell *cell = [tableview cellforrowatindexpath:indexpath]; if(cell == nil){ if(type == scene){ group *scene = [[appdata getscenes]objectatindex:lastrequestedpropertyposition]; [selectedarray addobject:scene.id]; }else if(type == product){ device *device = [[appdata getdevices]objectatindex:lastrequestedpropertyposition]; [selectedarray addobject:device.id]; } }else{ [selectedarray addobject:[nsnumber numberwithint:cell.tag]]; } }
datasource:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"protocell" forindexpath:indexpath]; if (!cell) { cell = [[uitableviewcell alloc]initwithstyle:uitableviewcellstyledefault reuseidentifier:@"protocell"]; } group *group = [[appdata getscenes] objectatindex:indexpath.row]; if(group != nil){ [cell.textlabel settext:group.name]; } cell.tag = group.id.intvalue; return cell; }
can tell went wrong here?
thanks
edit using makes separator disappear on select instead of keeping separator there.
- (void) tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { [tableview deselectrowatindexpath:indexpath animated:yes]; [tableview reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic]; [self.tableview selectrowatindexpath:indexpath animated:no scrollposition:uitableviewscrollpositionnone]; uitableviewcell *cell = [tableview cellforrowatindexpath:indexpath]; if(cell == nil){ if(type == scene){ group *scene = [[appdata getscenes]objectatindex:lastrequestedpropertyposition]; [selectedarray addobject:scene.id]; }else if(type == product){ device *device = [[appdata getdevices]objectatindex:lastrequestedpropertyposition]; [selectedarray addobject:device.id]; } }else{ [selectedarray addobject:[nsnumber numberwithint:cell.tag]]; } }
in tableview:didselectrowatindexpath
, if send both messages below, issue visually resolved (with probable performance cost).
[tableview deselectrowatindexpath:indexpath animated:yes]; [tableview reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic];
for work (for me), deselectrowatindexpath:animated:
must contain animated:yes
. animation used reloadrowsatindexpaths:withrowanimation:
doesn't matter.
Comments
Post a Comment