Change how profile header collection view cell is sized
Fixes crash due to collection view layout loop in some circumstances Closes #537
This commit is contained in:
parent
59af29ff64
commit
cc696e58fc
|
@ -63,11 +63,18 @@ class ProfileHeaderCollectionViewCell: UICollectionViewCell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// overrides an internal method
|
override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
|
||||||
// when the super impl is used, preferredLayoutAttributesFitting(_:) isn't called while the view is offscreen (i.e., window == nil)
|
switch state {
|
||||||
// and so the collection view imposes a height of 44pts which breaks the layout
|
case .unloaded:
|
||||||
@objc func _preferredLayoutAttributesFittingAttributes(_ attributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
|
return super.preferredLayoutAttributesFitting(layoutAttributes)
|
||||||
return preferredLayoutAttributesFitting(attributes)
|
case .placeholder(let heightConstraint):
|
||||||
|
layoutAttributes.size.height = heightConstraint.constant
|
||||||
|
return layoutAttributes
|
||||||
|
case .view(let profileHeaderView):
|
||||||
|
let size = profileHeaderView.systemLayoutSizeFitting(layoutAttributes.size, withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel)
|
||||||
|
layoutAttributes.size = size
|
||||||
|
return layoutAttributes
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum State {
|
enum State {
|
||||||
|
|
Loading…
Reference in New Issue