iphone - Problem with configuring a UITableView as a inclusive selection list -


i programing uitableview behave inclusive selection list. table displays correctly , allows multiple cells selected check boxes. problem cells have been selected (cells contain check mark right) loose selected status when scrolled out of view (cells check mark disappears). want selections made cells in table preserved if cells scrolled out of view. have idea causing this?

here code inside of tableviewcontroller class:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {  static nsstring *cellidentifier = @"cell";  uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) {     cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease]; }  nsuinteger row = [indexpath row]; cell.textlabel.text = [widgettitles_glob objectatindex:row]; cell.detailtextlabel.text = @""; cell.textlabel.textcolor = [uicolor blackcolor];  cell.textlabel.font = [uifont boldsystemfontofsize:15]; cell.accessorytype = uitableviewcellaccessorynone;  return cell; 

}

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { [tableview deselectrowatindexpath:[tableview indexpathforselectedrow] animated:yes]; uitableviewcell *cell = [tableview cellforrowatindexpath:indexpath]; if (cell.accessorytype == uitableviewcellaccessorynone) {     cell.accessorytype = uitableviewcellaccessorycheckmark;     // reflect selection in data model } else if (cell.accessorytype == uitableviewcellaccessorycheckmark) {     cell.accessorytype = uitableviewcellaccessorynone;     // reflect deselection in data model } 

}

any appreciated.

in cellforrowatindexpath: u assigining accessorytype none... whenevr u scroll delegate called , set accessory type none... u should change ur code .

i have faced prb once... came solution follows..

store indexpath.row values of selected indexpath in array(this code should in didselectrowatindexpath delegate) if deselected remove array.. in cellforrowatindexpath: method have used loop , check if indexpath.row present change accessory type checkmark else none


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -