ecerney / CollectionViewWaterfallLayout

Pinterest inspired layout for UICollectionViews
MIT License
493 stars 69 forks source link

Dynamic cell sizes #17

Open raulriera opened 8 years ago

raulriera commented 8 years ago

Is there a way to achieve this? It seems the library wants to hardcode the size of the cells in the delegate :/

rlam3 commented 8 years ago

+1 @raulriera were you able to find a workaround for this?

mbernson commented 8 years ago

Hi,

I initially had cells with dynamic height like so:

func collectionView(collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
  let measureCell = MyCell.measureCell
  let width = layout.collectionViewContentSize().width
  measureCell.frame = CGRect(x: 0, y: 0, width: width, height: 0)
  measureCell.layoutIfNeeded()
  return measureCell.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize)
}

But it's still buggy, for example the cells don't resize properly when the collection view's width changes. I'm still looking for a better way.

rlam3 commented 8 years ago

@mbernson should we be pulling all image ages during view did load with the size in the json and creating objects prior to having to set the cells sizes? or would there be a way to reload the cells once the image was downloaded?

leancmscn commented 8 years ago

have to hard code for it. cannot auto change if cell loading images.

podratz commented 7 years ago

Same with me: How do I get cells with dynamic height? As far as I see there is no public property providing the item-width. What was the intention behind hiding it and how should I calculate my cell's height without access to such a value? My cells contain multiline-labels, all of which have dynamic content hence a dynamic height.

podratz commented 7 years ago

My fork solved the problem. I added a read-only dictionary caching the widths of the cells in all your sections.

maulikshah09 commented 3 years ago

@nickpodratz please help me... I have dynamic Height in header view and my layout is strugged layout.. this layout is working fine.I don't know what is the issue.. when I set static height then every label everything increased but when I set dynamic then some lable not increased.