Remove white line next to reorder control on grouped UITableViewCell

What is happening is that when UITableViewCell shows the reorder control it also adds an empty, 1 pixel wide, white UIView to its array of subviews.

Bluntly: this is a bug that Apple should fix.

However, you can get around it by finding that annoying view every time it appears and setting its background color to transparent. Quick tip: the annoying white view is always the last in the UITableViewCell's subviews array and is always 1 pixel wide. We will use this to find it.

When you turn editing on for the table, make all of the visible annoying 1 pixel views transparent. So the action method which toggles "edit" mode on the table might look like this:

- (IBAction)edit:(id)sender
{
    [tableView setEditing:!tableView.editing animated:YES];

    for (UITableViewCell *cell in [tableView visibleCells])
    {
        if (((UIView *)[cell.subviews lastObject]).frame.size.width == 1.0)
        {
            ((UIView *)[cell.subviews lastObject]).backgroundColor =
                [UIColor clearColor];
        }
    }
}

and keep doing so for all new views as they become visible by implementing this in your UITableViewDelegate:

- (void)tableView:(UITableView *)tableView
    willDisplayCell:(UITableViewCell *)cell]
    forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (((UIView *)[cell.subviews lastObject]).frame.size.width == 1.0)
    {
        ((UIView *)[cell.subviews lastObject]).backgroundColor =
             [UIColor clearColor];
    }
}

This hack to fix the problem is fairly innocuous and if Apple fix the bug in future (stop adding the annoying 1 pixel view), this code should quietly stop doing anything.


No quick answer here, but can you determine what specific View is responsible for this white line?

One trick I use sometimes to "debug" these kinds of problems is to change the background colors of the Views that are the likely suspects. I might set the background color of the TableViewCell as well as its contentView to red or blue and see if you can change the color of the line. That will at least give you a clue as to the nature of the problem and maybe some ideas about how to solve it.


After trying the solutions from @matt-gallagher and @bryce, I combined the two and created an override of setEditing.

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {

    [super setEditing:editing animated:animated];

    for (UIControl *control in self.subviews) {
        if (control.frame.size.width == 1.0f) {
            control.backgroundColor = [UIColor clearColor];
        }                
    }
}