i having tableview , want know how can change selected row's text color, red ? tried code :
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell= [[[uitableviewcell alloc] initwithframe:cgrectzero reuseidentifier:nil] autorelease]; cell.text = [localarray objectatindex:indexpath.row]; return cell; } - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { cityname = [localarray objectatindex:indexpath.row]; uitableviewcell* thecell = [tableview cellforrowatindexpath:indexpath]; thecell.textcolor = [uicolor redcolor]; //thecell.textlabel.textcolor = [uicolor redcolor]; [tableview deselectrowatindexpath:indexpath animated:no]; }
(1) when select row text color changed red when select selected row's text remains red. how can solve ?
(2) when scroll table text color change black color how solve ?
thanks..
do in tableview:cellforrowatindexpath:
:
cell.textlabel.highlightedtextcolor = [uicolor redcolor];
(and don't use cell.text = ...
anymore. has been deprecated 2 years now. use cell.textlabel.text = ...
instead.)
as raphael oliveira mentioned in comments, if selectionstyle of cell equals uitableviewcellselectionstylenone
won't work. check storyboard selection style.
Comments
Post a Comment