Is there a simple way to get an NSScrollView
to adapt to its document view changing size when using auto layout?
I have tried to call both setNeedsUpdateConstraints:
and setNeedsLayout:
on the document view, the clip view and the scroll view, without any results.
fittingSize
of the document view reports the correct size.
The problem is that the document view, which holds subviews, is not re-sized when the subviews change their size, even if they call invalidateIntrinsicContentSize
. The contents of the document view are hence clipped to the original size of the document view as they grow. The document view is created in a nib and set as the scroll view's document view in an awakeFromBib
method.
I was hoping that the document view frame would automatically be adjusted when its fittingSize
changes, and the scrollbars updated accordingly.
NSPopover
does something similar - provided that the subviews of the content controller's view have the constraints set right and various content hugging values are high enough (higher than the hidden popover window's hight constraint priority, for one).