How to remove a UITableViewCell action on a finger touch?

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

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

But there's a problem. When the user clicked on a cell, he changed the color to blue. But I do not want to see the reaction when the user clicks.

See screenshots.

enter image description here

tapping action

enter image description here

+4
source share
4 answers

set the selection style to none

 cell.selectionStyle = UITableViewCellSelectionStyleNone; 

Do not use - cell.userInteractionEnabled = NO; Or your buttons will not work.

+8
source

There are several ways:

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

2. cell.selectionStyle = UITableViewCellSelectionStyleNone; (to turn off the backlight)

3. tableView.allowsSelection = NO; (disables backlighting only for the whole table)

4. tableView.UserInteractionEnabled:NO; (to make the whole table "finished only" - including buttons)

+4
source

cell.selectionStyle = UITableViewCellSelectionStyleNone;

0
source

Swift 4 solution :

 // disable selection for a specific cell cell.selectionStyle = .none // disable selection for all cells inside your TableView tableView.allowsSelection = false 
0
source

Source: https://habr.com/ru/post/1381198/


All Articles