0

I have UIScrollView with horizontal scrolling direction and dynamic height (user can change the height when finger moved). I need to make cells able to resize itself when UIScrollView change height (UICollectionView.frame.size = SomeCell.frame.size).

I try to make this with set cells width and height constraints to superview (UICollectionView) but its not working (all cells have some position).

Note: I want to keep compatibility with devices on iOS 9 and newer.

LinusGeffarth
  • 21,607
  • 24
  • 100
  • 152
  • 2
    Possible duplicate of [UICollectionView Self Sizing Cells with Auto Layout](https://stackoverflow.com/questions/25895311/uicollectionview-self-sizing-cells-with-auto-layout) – LinusGeffarth May 17 '19 at 10:59
  • If you use auto-layout like in the duplicate I mentioned, you can just update the height constraint and then the cell should update. You might have to call some layout methods after updating the constraint's constant. – LinusGeffarth May 17 '19 at 11:00
  • I try it, but its not working. All cells equal estimatedSize in flowLayout. – Paul Seagul May 17 '19 at 11:01
  • Have you set that to automatic? `flowLayout.estimatedItemSize = .automaticSize` (from [here](https://stackoverflow.com/a/42948877/3397217)) – LinusGeffarth May 17 '19 at 11:03
  • I need compatible with iOS 9+ – Paul Seagul May 17 '19 at 11:05

0 Answers0