I need the header view for a section to be a UIImageView
and a UILabel
below it. The height for the image view is not going to change once created, but the text in the label may change as a result of some user actions. I need to update the height for the whole header view dynamically (using AutoLayout, not changing the frame).
I've been checking some posts, for example this one, but solutions I tried are not working for me. The height of my header view is not updated when I change the text in the label.
Maybe I need to understand how does this work from the beginning. Firstly, I'd like to be clear about this:
What is the difference between providing a header view as a subclass of
UIView
intableView(_:viewForHeaderInSection:)
, and providing it as a subclass ofUITableViewHeaderFooterView
and registering it to the table view?Which constraints do the subviews in the header view need to be able to have a dynamic height?
How should I dynamically update the height of the header view?