objective c - Selection in TableViewCell -
on selection of tableviewcell, change color of tableviewcell. when select cell on tableviewcell , scroll other cell selected.
after scroll other cell affected
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
Post a Comment