0

I want a collectionview cell should be the dynamic height. I am getting data from server and loading in to tableview inside collectionview cell. That cell height should be change according to the table cell height, I am getting till here. But the problem is The cells are not aligning from the top. see this pic. The cell should create from top. This is demo code. Thanks

rmaddy
  • 314,917
  • 42
  • 532
  • 579

2 Answers2

0

If I'm understanding your problem correctly, try setting self.yourCollectionView.automaticallyAdjustsScrollViewInsets = false

Grant Park
  • 1,004
  • 1
  • 9
  • 29
0

You will need to extend UICollectionViewLayout. And then in the prepareLayout method, you will need to specify the calculated frames of every item of your collectionview. There are two tutorials: http://www.skeuo.com/uicollectionview-custom-layout-tutorial is a very good tutorial for custom layout.

https://github.com/betzerra/MosaicLayout and https://www.cocoacontrols.com/controls/rfquiltlayout is pretty much what you want. A related question about rfquiltlayout on stackoverflow is RFQuiltLayout and UICollectionView

Community
  • 1
  • 1
rd_
  • 395
  • 3
  • 13