From b58cfbe1753a2d25322c4bb9738e09f13e420d0c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 24 Jan 2024 16:50:58 -0600 Subject: [PATCH] added contentHugging and compressionResistance Signed-off-by: Matt Bruce --- VDS/Classes/SelfSizingCollectionView.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/VDS/Classes/SelfSizingCollectionView.swift b/VDS/Classes/SelfSizingCollectionView.swift index b75e61e4..70ccc083 100644 --- a/VDS/Classes/SelfSizingCollectionView.swift +++ b/VDS/Classes/SelfSizingCollectionView.swift @@ -60,6 +60,10 @@ public final class SelfSizingCollectionView: UICollectionView { // MARK: - Private Methods //-------------------------------------------------- private func setupContentSizeObservation() { + //ensure autoLayout uses intrinsic height + setContentHuggingPriority(.required, for: .vertical) + setContentCompressionResistancePriority(.required, for: .vertical) + // Observing the value of contentSize seems to be the only reliable way to get the contentSize after the collection view lays out its subviews. self.contentSizeObservation = self.observe(\.contentSize, options: [.old, .new]) { [weak self] _, change in // If we don't specify `options: [.old, .new]`, the change.oldValue and .newValue will always be `nil`.