views:

65

answers:

2

I want to be able to reorder cells in a table, but not to delete or insert them.

I want a picture like this:

image from table view programming guide

This image appears in Apple's Table View Programming Guige, but the code samples there produce a table with red "delete" buttons when the table goes into editing mode.

I can set editingStyleForRowAtIndexPath to UITableViewCellEditingStyleNone and that makes the delete buttons go away, but the rows are still indented as if to make room for these buttons.

A: 

You should compensate for this when drawing the contents of your cell.

In drawRect:

if (self.editing && self.editingStyle != UITableViewCellEditingStyleNone) {
      // Adjust frame
    }
Diederik Hoogenboom
Are you saying the only way to avoid the indentation is to go all the way into drawRect? This makes no sense.You say override drawRect, but it's not even clear to me which drawRect I would need to override. The cell's frame stays constant size. What adjusts is the frame of one of the subviews. I wonder if you can point me to a more complete code fragment.
iter
A: 

The answer turns out to be shouldIndentWhileEditing. This is a property of UITableCellView, You can set it directly on a cell, or through the UITableViewDelegate protocol.

- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
    return NO;
}
iter
but it still shows the minus sign.. Is there any way to dissapear minus sign ?
Suriya
editingStyleForRowAtIndexPath is your friend. Make sure it returns UITableViewCellEditingStyleNone
iter