I have a project that uses self-sizing table view cells. I'd like to animate when the height of a cell changes. NSTableView's noteHeightOfRows(withIndexesChanged:)
will do this for view-based cells, but only when providing the height explicitly in the delegate's tableView(_, heightOfRow:)
method. When cell height is calculated with auto layout, this value is ignored.
I can get the cell view itself to animate, but its containing row view jumps to the final size dictated by the constraints. Also tried using a height constraint on the row view and animating that, but it also was ignored. Anyone left developing Mac apps that has solved this problem?
I created a sample project and put it on Github, that animates the row height of a table. It does not use the delegates tableView(_, heightOfRow:)
function. Take a look at it.
The necessary steps:
beginUpdate()
and endUpdate()
on the table view.noteHeightOfRows(withIndexesChanged:)
on the table within a call to NSAnimationContext.runAnimationGroup
.However it is easier if you just look at the code I put on Github.