objective c - Selection in TableViewCell -


on selection of tableviewcell, change color of tableviewcell. when select cell on tableviewcell , scroll other cell selected.enter image description here

after scroll other cell affected

enter image description here

this code

static nsstring *identifier = @"tbdcreategameplayercell";  tbdcreategameplayercell *playercell = (tbdcreategameplayercell *)[tableview dequeuereusablecellwithidentifier:@"tbdcreategameplayercell"];  if (!playercell) {     nslog(@"creating new cell : %d",row);     nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"tbdcreategameplayercell" owner:nil options:nil];     playercell = [nib objectatindex:0];   } 

you must implement delegate method:

- (void)tableview:(uitableview *)tableview   willdisplaycell:(uitableviewcell *)cell forrowatindexpath:(nsindexpath *)indexpath 

inside method change cell background default color.

from apple docs:

discussion

a table view sends message delegate before uses cell draw row, thereby permitting delegate customize cell object before displayed. method gives delegate chance override state-based properties set earlier table view, such selection , background color. after delegate returns, table view sets alpha , frame properties, , when animating rows slide in or out.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -