Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display UITableViewCell reordering control without shifting cell contents to the right?

I implemented moveRowAtIndexPath to rearrange the order of the cells in a UITableView and set UITableViewCellEditingStyleNone so it displays only the reordering controls when in editing mode.

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {

    return UITableViewCellEditingStyleNone;

}

It works fine but when entering in editing mode it still indents the contents of each cell to the right expecting to make room for a deletion or insertion control. I am not using either so it becomes an odd empty space. Is there a way to avoid this behavior in editing mode?

like image 970
Guto Araujo Avatar asked Dec 13 '12 01:12

Guto Araujo


2 Answers

Have you tried setting shouldIndentWhileEditing to NO on your UITableViewCell?

like image 77
Shaun Avatar answered Nov 14 '22 22:11

Shaun


Try This UITableViewDelegate Methods. It will allow reordering without showing the Delete button on left and without shift the row to right:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

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

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

- (BOOL)tableView:(UITableView *)tableview canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}
like image 36
Evana Avatar answered Nov 14 '22 21:11

Evana