When using moveRowAtIndexPath:toIndexPath:
to move a UITableViewCell
, I'm seeing an animation glitch when using estimatedRowHeight
and UITableViewAutomaticDimension
when the cell animates from a visible state to a non-visible state.
The issue disappears if I explicitly set the height of cells by implementing tableView:heightForRowAtIndexPath:
. The issue only appears when the source and destination index paths are visible and non-visible, respectively. When the cell is moving to another visible index path, the animation behaves as expected.
I've created a sample project to illustrate the effect: https://github.com/timarnold/Table-Cell-Sizing-Bug
http://www.openradar.me/19156703
@rdelmar pointed out that my question doesn't actually ask a question.
Does anyone know of a way to work around this bug and fix this behavior? Or am I doing something wrong?
I used one of my Apple-provided developer support tickets to inquire about this issue with Apple. They confirmed that it was a bug (visit http://www.openradar.me/19156703 to dupe) and didn't provide any workarounds.
Try to cache cell heights.
private var cellHeights = [NSIndexPath: CGFloat]()
override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if let cachedHeight = cellHeights[indexPath] {
return cachedHeight
} else {
return 60
}
}
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cellHeights[indexPath] = cell.frame.height
}
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