Ivan Cantarino
Ivan Cantarino

Reputation: 3246

TableView edit mode doesn't animate cells

I have implemented a UITableViewController which has a custom UITableViewCell.

In that tableView I have an Edit button, which allows me to delete some rows, however when I try to do it the cells don't animate to the right side as usual and I've no idea why this is happening.

Here's an image of what I'm referring to:

img

When I tap the Edit button, the following function is called:

@objc func showEditing() {
    tableView.setEditing(!tableView.isEditing, animated: true)
    rightButton.title = (tableView.isEditing) ? "Done" : "Edit"
}

Do you know what may be causing this issue?

Thanks.

Upvotes: 2

Views: 403

Answers (1)

EmilioPelaez
EmilioPelaez

Reputation: 19892

UITableViewCell has a contentView property where all the content should be. That view is resized in situations like this one, or when you show the reorder indicators.

It seems to me like you constrained your labels to the cell, if you use the contentView instead of the cell, your labels should adjust properly when the delete and reorder images are shown.

Upvotes: 3

Related Questions