ios - UITableViewCell preserve selected on UITableView scrolling -
i have uitableview on ipad. when cell selected , cell scrolled off screen, , scrolled screen, selected cell blank. problem occurs on device , not on simulator. have tried various of proposed solutions manage selected index
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { self.selectedindexpath = indexpath; }
and use setselected/selectrowatindexpath on cellforrowatindexpath like
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"desktop row"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell =[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } ... if(self.selectedindexpath!=nil){ if ((indexpath.row == self.selectedindexpath.row) && (indexpath.section == self.selectedindexpath.section)) { [self.tableview selectrowatindexpath:self.selectedindexpath animated:yes scrollposition:uitableviewscrollpositionnone]; } } return cell; }
but nothing works, saw similar questions people ask have different , strage.
any ideas appreciated.
Comments
Post a Comment