1

I have a table view and custom TableViewCell with configure to allow multiple cell to be selected in editing mode and a check-mark will showing when I selected cell.

tableView.allowsMultipleSelectionDuringEditing = YES

I want to prevent the blue highlight when I selected my cell in editing mode.

I have try many ways like configure cell selection style but with this configure the "check-mark" won't be show in editing mode when cell selected.

cell.selectionStyle = UITableViewCellSelectionStyleNone;

I really need helps in this case. Thanks.

sunsunai
  • 161
  • 4
  • 11

3 Answers3

3

You can overwrite the selectedBackgroundView property of your custom tableViewCell this line of code works for me

[cell setSelectedBackgroundView:[[UIView alloc]initWithFrame:CGRectMake(cell.frame.origin.x, cell.frame.origin.x, cell.frame.size.width, cell.frame.size.height)]];
Reinier Melian
  • 20,519
  • 3
  • 38
  • 55
2

One method is to overwrite setHighlighted:animated: in your cell:

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
    // do nothing
}

This will block the highlighting behavior, not the selection behavior. The selection can be completely overriden using:

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    // update UI for selection state
}
Sulthan
  • 128,090
  • 22
  • 218
  • 270
0

Swift:

cell.selectedBackgroundView = UIView(frame: cell.frame) or

cell.selectedBackgroundView.isHidden = true

But it may still not work as you expect. When selected all of the cell's subviews' backgroundColor to clear color(transparent), you may want to recover it

fujianjin6471
  • 5,168
  • 1
  • 36
  • 32