iphone - Turning a cell in a UITableView on/off on the same cell, in the same view -
is possible make 1 cell in uitableview have on/off behavior? basically, when click cell, becomes green, want. doesnt go viewcontroller or anything. when click same cell again, in same view, want green disappear , return it's previous color state.
this how have didselectrowatindexpath
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { nsstring *selectedphrase = [datatable objectatindex:indexpath.row]; [self setcurrentphrase:selectedphrase]; }
this seems easy question. know can drop in [tableview deselectrowatindexpath:indexpath animated:yes];
makes unhighlighted right away after click it.
thanks!
aaron
you change background color of uitableviewcell
on selection, may use bool tell fill in background (whether green or clear color).
access cell through below method
- (uitableviewcell *)cellforrowatindexpath:(nsindexpath *)indexpath
use below reference code.
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { nsstring *selectedphrase = [datatable objectatindex:indexpath.row]; [self setcurrentphrase:selectedphrase]; mycutsomcell* mycell= (mycutsomcell*)[tableview cellforrowatindexpath:indexpath]; if(mycell.isgreen) { //change backgroundcolor green } else { //clear backgroundcolor } mycell.isgreen = !mycell.isgreen; }
Comments
Post a Comment