Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove UITableViewCell Edit Mode Indentation?

I have a grouped UITableView and when going into edit mode, the cells indent. I need to stop the cells indenting when going into edit mode.

I have tried two things:

cell.shouldIndentWhileEditing = NO;

and

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

Neither of these stop cell indentation upon entering edit mode.

like image 636
Josh Kahane Avatar asked Mar 29 '12 21:03

Josh Kahane


1 Answers

Do it the way documentation suggests, quoting [UITableViewCell willTransitionToState:]:

Subclasses of UITableViewCell can implement this method to animate additional changes to a cell when it is changing state. UITableViewCell calls this method whenever a cell transitions between states, such as from a normal state (the default) to editing mode. The custom cell can set up and position any new views that appear with the new state. The cell then receives a layoutSubviews message (UIView) in which it can position these new views in their final locations for the new state. Subclasses must always call super when overriding this method.

In other words, you can change the position and size of the [UITableViewCell contentView] in [UITableViewCell layoutSubviews, to cancel the indendation.

like image 127
Sulthan Avatar answered Oct 11 '22 14:10

Sulthan