Currently I am able to tap a cell and select it using didSelectRowAtIndexPath
. However, I am unable to deselect it when tapped. I wish to toggle these two features.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var selectedCell = tableView.cellForRowAtIndexPath(indexPath)!
selectedCell.backgroundColor = UIColor.purpleColor()
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
- I have a
TableView
in myView Controller
. - The
dataSource
anddelegate
are already set up. - Multiple selection is enabled in
UIBuilder
for the table.