4thSpace 4thSpace - 4 months ago 33
iOS Question

How to disable UITableViewCell highlighting?

I have a dark gray view background with a transparent tableview. I'm using the following code to try and stop cell highlight when a cell is clicked. It works except right when the cell is initially clicked, I see a highlight. I then transition to another scene after that. When I come back, the cell is not highlighted.

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var selectedCell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!
selectedCell.contentView.backgroundColor = UIColor.clearColor()
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}


How do I disable the initial cell highlighting that is still going on?

Answer

Set UITableViewCell selection style none

cell.selectionStyle = .None