The above 3 lines of code were missing and are probably the most significant omission - in order to calculate the height, the cell must be configured correctly, and the constraints must be added as well.