Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cells not getting selected in UITableView with allowsMultipleSelectionDuringEditing set in edit mode

I have a UITableView that is configured to allow multiple cells to be selected in edit mode. However, the empty white circles on the left never change to red circles with the white checkmarks inside after a cell is touched/selected.

I have read about the swipe to delete issue with allowsMultipleSelectionDuringEditing, so my setEditing:animinated method looks like this:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    self.tableView.allowsMultipleSelectionDuringEditing = editing;
    [super setEditing:editing animated:animated];
}

Some resources on the Net suggest setting allowsSelectionDuringEditing = NO;, but that has no effect. Also, my cell editing style is set to UITableViewCellEditingStyleDelete, and changing it does not have any effect either.

When a row is touched in edit mode, tableView:didSelectRowForIndexpath: is triggered, but as mentioned above, the UI does not reflect this.

like image 400
dandan78 Avatar asked Oct 03 '12 12:10

dandan78


2 Answers

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

The problem was in my implementation of tableView:cellForRowAtIndexPath:, where I was setting the cell's selectionStyle property to UITableViewCellSelectionStyleNone. For some reason, this has the added 'benefit' of disabling the red checkmark on the left hand side in multiselection edit mode.

Setting cell.selectionStyle = UITableViewCellSelectionStyleGray; fixed the issue.

like image 67
dandan78 Avatar answered Oct 03 '22 07:10

dandan78


Old thread but i also had this issue, however i found the cause to be my custom cell was overriding the setSelected and setHighlighted methods without call super.

This resulted in the cells not becoming selectable.

like image 28
Dan Avatar answered Oct 03 '22 07:10

Dan