Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove UITableViewCell action on finger tap?

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

like image 572
Voloda2 Avatar asked Nov 14 '11 21:11

Voloda2


2 Answers

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.

like image 63
shannoga Avatar answered Sep 21 '22 11:09

shannoga


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)

like image 31
Bo A Avatar answered Sep 19 '22 11:09

Bo A