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 tableview in view controller.
  • the datasource , delegate set up.
  • multiple selection enabled in uibuilder table.

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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -