Cells that are not selected in a UITableView allow you to use MultipleSelectionDuringEditing in edit mode

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

I read about removal to remove the problem with allowsMultipleSelectionDuringEditing , so my setEditing:animinated looks like this:

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

Some resources on the network suggest setting allowsSelectionDuringEditing = NO; but it does not affect. In addition, my cell editing style is set to UITableViewCellEditingStyleDelete , and changing it also has no effect.

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

+4
source share
4 answers

This was usually the case, my mistake.

The problem was my implementation of tableView:cellForRowAtIndexPath: where I set the cell selectionStyle property to UITableViewCellSelectionStyleNone . For some reason this has the added โ€œbenefitโ€ of disabling the red checkmark on the left side in multi-segment editing mode.

Setting cell.selectionStyle = UITableViewCellSelectionStyleGray; fixed the problem.

+19
source

The old thread, but I also had this problem, however, I found that the reason for my custom cell was to override the setSelected and setHighlighted methods without calling super.

This made it impossible to select cells.

0
source

I had a similar problem because I worked very hard to make sure my cameras never showed any choice (for the chat bubble table style).

So, of course, this fix led to large, large colored stripes on my desk, and I had to find another way to get rid of them.

In your cellForRowAtIndexPath you can set selectedBackgroundView instead of setting selectionStyle, and also enable checkboxes. The view may be the color of your cell, or clearColor, and then nothing will appear. Here is my code:

 static dispatch_once_t onceToken; static UIView * selectedBackgroundView; dispatch_once(&onceToken, ^{ selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame]; selectedBackgroundView.backgroundColor = APP_CELL_BACKGROUND_COLOR; }); cell.selectedBackgroundView = selectedBackgroundView; 
0
source

I had the same problem. Make sure tableView:shouldHighlightRowAtIndexPath: returns YES , otherwise the selection will not happen, at least in iOS 7.

 - (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } 
0
source

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


All Articles