How can I set the UITableView\'s cell property to be unselectable? I don\'t want to see that blue selection box when the user taps on the cell.
Set cell.userInteractionEnabled = NO;
If you have designed your cell in Interface Builder, you can do this by removing the checkbox from 'User Interaction Enabled' for the tableViewCell
.
Swift 4:
You can prevent selection and highlighting by using the UITableViewDelegate: shouldHighlightRowAt
This answer assumes you have a custom cell created named: CustomTableViewCell
And that you created a boolean inside that custom cell named: isSelectable
func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
let cell = tableView.cellForRow(at: indexPath) as! CustomTableViewCell
if cell.isSelectable == false {
return false
} else {
return true
}
}
This is the Swift version of Sebastian Celis's objc answer.
Had this problem, too, tried everything already mentioned. The final trick, which got rid of the "blue flash" at selecting a table cell was adding this line:
self.myTableView.allowsSelection = NO;
Not sure whether it was this one line or everything combined, but as total grand result I get no more blue selection or even the blue flash. Happy!