UITableViewCellSelectionStyleNone whilst still showing checkmark in edit mode

I am having issues setting the cell background colour on a grouped table cell when in edit mode. It seems to get the checkmark to appear a selection style has to be set and the only options are UITableViewCellSelectionStyleBlue or UITableViewCellSelectionStyleGray. What I am after is the for the checkmark just to be selected and the cell remain white when it is checked.

You would have thought UITableViewCellSelectionStyleNone would have this behaviour but this stops the checkmark for showing.

UITableViewCellSelectionStyleNone no checkmark shows when selected

I have tried to use setSelectedBackgroundView. This would work if the cell style was not grouped but as it is the round corners do not get drawn.

Custom background view problem with corners.

The properties for the cell above are

    cell.selectionStyle = UITableViewCellSelectionStyleGray;
    cell.backgroundView = [self tableViewCellRowBackground];

Where tableViewCellRowBackground is a UIView with orange background. The editMode is the built in iOS table edit mode with the following properties set on the table

    self.tblFiles.allowsMultipleSelectionDuringEditing = YES;

¿Alguna idea?

preguntado el 30 de julio de 12 a las 11:07

Can you show your code for cellForRowatIndexPath?? -

@iPhoneDeveloper I have added some small snippets of code. -

Where have you given the UITableViewCellSelectionStyleNone?? -

That was for the example at the start. That replaces the cell.selectionStyle = UITableViewCellSelectionStyleGray; it is in the cell for row method. -

2 Respuestas

cell.backgroundView = [self tableViewCellRowBackground];

This method is setting an image for your selected cell.You should check out this one to make the selection Style image nil.

Respondido 30 Jul 12, 12:07

I have tried setting this to nil but then there is no background at all (not even the white cell background). - bencallis

Show the code which you are using in this method: (UIView*)tableViewCellRowBackground; - Tripti Kumar

I assume I should be using this as well as setting the selection style to tray/blue? - bencallis

In the end I had to create my own custom cells by overriding the drawrect method.

Respondido 02 ago 12, 19:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.