7

I've just created UITableViewCell. I added to it two buttons. Then I set transparent background to the cell.

cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];

But there is a problem. When user tapped on cell it changed the color to blue. But I don't want to see any reaction when a user is tapping.

Please see screenshots.

enter image description here

tapped action

enter image description here

Voloda2
  • 12,359
  • 18
  • 80
  • 130
  • 1
    Duplicate entry [http://stackoverflow.com/questions/190908/how-can-i-disable-the-uitableview-selection-highlighting][1] [1]: http://stackoverflow.com/questions/190908/how-can-i-disable-the-uitableview-selection-highlighting – defvol Nov 14 '11 at 21:18
  • This might be a duplicate entry [http://stackoverflow.com/questions/190908/how-can-i-disable-the-uitableview-selection-highlighting][1] [1]: http://stackoverflow.com/questions/190908/how-can-i-disable-the-uitableview-selection-highlighting – defvol Nov 15 '11 at 01:12

4 Answers4

11

Update for Swift 5:

set the selection style to none

    cell.selectionStyle = .none;

Don't use - cell.isUserInteractionEnabled = false Or your buttons won't work.

colin
  • 761
  • 1
  • 11
  • 24
shannoga
  • 19,649
  • 20
  • 104
  • 169
6

There are a few ways:

1.cell.userInteractionEnabled = NO; (to make cell 'ready-only' - this includes the buttons)

2.cell.selectionStyle = UITableViewCellSelectionStyleNone; (to disable just highlighting)

3.tableView.allowsSelection = NO; (disables just highlighting for whole table)

4.tableView.UserInteractionEnabled:NO; (to make whole table 'ready-only' - including buttons)

Bo A
  • 3,144
  • 2
  • 33
  • 49
0

cell.selectionStyle = UITableViewCellSelectionStyleNone;

0

Swift 4 solution:

// disable selection for a specific cell
cell.selectionStyle = .none

// disable selection for all cells inside your TableView
tableView.allowsSelection = false
budiDino
  • 13,044
  • 8
  • 95
  • 91