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?
Have you tried setting shouldIndentWhileEditing to NO on your UITableViewCell?
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With