ios - Is it possible to get notified if user clicks on UITableView sectionIndex -
i want change the color of section index of uitableview
, if user clicks on it.
i can set sectionindexcolor
, sectionindextrackingbackgroundcolor
while initializing tableview , on other state, i've found no method change index color on click.
update:
i mean a-z side bar @ larger tableviews. here images (see grey bar @ image 2)
unselected state:
selected state:
i have rather dirty solution this, apple not support public api. implemention works quit , should not crash if api changes in future (just not work anymore). subclassing uitableview
, adding own callbacks sectionindex view on time added subview table.
@interface mytableview : uitableview @end @implementation mytableview - (void)selectionstarted { [self setsectionindexcolor:[uicolor greencolor]]; } - (void)selectionstoped { [self setsectionindexcolor:[uicolor redcolor]]; } - (void)addsubview:(uiview *)view { [super addsubview:view]; if ([nsstringfromclass([view class]) isequaltostring:@"uitableviewindex"] && [view iskindofclass:[uicontrol class]]) { uicontrol *cont = (uicontrol *)view; [cont addtarget:self action:@selector(selectionstarted) forcontrolevents:uicontroleventtouchdown]; [cont addtarget:self action:@selector(selectionstoped) forcontrolevents:uicontroleventtouchupinside]; [cont addtarget:self action:@selector(selectionstoped) forcontrolevents:uicontroleventtouchupoutside]; [cont addtarget:self action:@selector(selectionstoped) forcontrolevents:uicontroleventtouchcancel]; } } @end
Comments
Post a Comment