Remove UITableViewCell edit mode indents?

I have a grouped UITableView and when I switch to edit mode, the cells recede. I need to stop the indentation of cells when I switch to edit mode.

I tried two things:

cell.shouldIndentWhileEditing = NO; 

and

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

None of them stop indenting a cell when entering edit mode.

+6
source share
1 answer

Do this as the documentation suggests, quoting [UITableViewCell willTransitionToState:] :

UITableViewCell subclasses can implement this method to animate additional changes to the cell when the state changes. UITableViewCell calls this method whenever a cell switches between states, for example, from a normal state (default) to edit mode. A custom cell can customize and place any new views that appear in a new state. The cell then receives a layoutSubviews (UIView) message in which it can position these new views at its final locations for the new state. A subclass should 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 subtask.

+7
source

Source: https://habr.com/ru/post/911987/


All Articles