13

I'm set editing mode for UITableView to have a possibility of cell reordering. UITableViewCellEditingStyleNone is returned by editingStyleForRowAtIndexPath: method for every cell, but it reserve some area on the left of cell. Is it possible to prevent such an area reserving, because I'm not need an insert or delete icon on left? In short, i want have a cell that occupate all available area and still can be reordered.

Yuriy Zhyromskiy
  • 149
  • 1
  • 2
  • 7

5 Answers5

38

// UITableViewDelegate

- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
    return NO;
}
memmons
  • 40,222
  • 21
  • 149
  • 183
Moss
  • 381
  • 3
  • 3
8

See the docs: You can set a boolean on the cell to make it not indent. Just add

cell.shouldIndentWhileEditing = NO;

to wherever you create your cell.

coneybeare
  • 33,113
  • 21
  • 131
  • 183
  • 1
    Thanks a lot, it works. Miss that option somewhat :( I'm use - (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath { return NO; } because i need it for all cells. – Yuriy Zhyromskiy Feb 22 '10 at 14:37
0

Set this to like 2 or 3

tableView:indentationLevelForRowAtIndexPath:

Jab
  • 26,853
  • 21
  • 75
  • 114
0

Do both

- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
    return NO;
}

and

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewCellEditingStyleNone;
}

in your UITableViewDelegate. Otherwise the cell content is indented.

timaktimak
  • 1,380
  • 1
  • 12
  • 21
0

The shouldIndentWhileEditing property only works with grouped tables. I found that setting an indentation level of -3 does the job for plain tables. Is there a better way? Here's what I'm using now:

    if (self.tableView.style == UITableViewStylePlain) {
        cell.indentationLevel = -3;
    } else if (self.tableView.style == UITableViewStyleGrouped) {
        cell.shouldIndentWhileEditing = FALSE;
    }
arlomedia
  • 8,534
  • 5
  • 60
  • 108
  • Actually shouldIndentWhileEditing works for plain tables for me, but your way of solution is possible too. Some kind of hackish however :) – Yuriy Zhyromskiy Dec 15 '10 at 10:54