ios - Selecting and Deselecting UITableViewCells - Swift -
currently able tap cell , select using didselectrowatindexpath. however, unable deselect when tapped. wish toggle these 2 features.
func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { var selectedcell = tableview.cellforrowatindexpath(indexpath)! selectedcell.backgroundcolor = uicolor.purplecolor() tableview.deselectrowatindexpath(indexpath, animated: true) } - i have
tableviewinview controller. - the
datasource,delegateset up. - multiple selection enabled in
uibuildertable.
i have sworn tried before , didn't work then.
i decided use 2 functions..
func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { var selectedcell = tableview.cellforrowatindexpath(indexpath)! selectedcell.backgroundcolor = uicolor.purplecolor() } func tableview(tableview: uitableview, diddeselectrowatindexpath indexpath: nsindexpath) { var deselectedcell = tableview.cellforrowatindexpath(indexpath)! deselectedcell.backgroundcolor = uicolor.clearcolor() }
Comments
Post a Comment