ios - Adding checkmark to selected table cell also checks another table cell -


when adding checkmark selected table cells, im seeing check appear in other cells also.

my didselectrowatindexpathcode is:

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     pfobject *player = [squadlistarray objectatindex:indexpath.row];     nsstring *playername = [player valueforkey:@"fullname"];     nslog(@"%@", playername);      uitableviewcell *selectedcell = [tableview cellforrowatindexpath:indexpath];      selectedcell.accessorytype = uitableviewcellaccessorycheckmark; } 

the nslog has expect results, showing 1 selection.

any ideas? need me show other code?

thanks

in cellforrowatindexpath can't configuring cell when cell gets reused. should setting (and resetting) of properties of cell data model.


you must have data model being used tell table view how many rows has , each cell should like. during didselectrowatindexpath should updating data model selected information. then, in cellforrowatindexpath, can use information in data model decide if cell has checkmark or not. if add it, if doesn't explicitly remove (to prevent being left there if cell reused).


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -