Home > Net >  allowsMultipleSelectionDuringEditing not working with Custom UITableviewCell
allowsMultipleSelectionDuringEditing not working with Custom UITableviewCell

Time:01-27

Referance enter image description here

CodePudding user response:

It was, as tends to be the case, my mistake

After searching a lot I realized the issue.

The problem was mostly we all set the cell's selectionStyle property to .none from Storyboard or programmatically to remove the background color of the cell during the selection.

Keep in mind that if you want to use the default selection or multiple selections feature during the editing must you need to follow this

Set the Selection Style from Storyboard

enter image description here

You can also Set in table views cellForRowAt method

cell.selectionStyle = .none

To remove or change the background color of the cell for the selection you need to use this override method in UITableViewCell

override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)
    self.backgroundColor = selected ? .gray : .white
}
  •  Tags:  
  • Related