Dynamically size cells to adjusted height
I was looking around stackoverflow for answers on this and yours seemed to be the best on this random question about dynamic cell resizing.
I have a UiCollectionView and I am looking to dynamically size cells according to their height relative to the devices width.
Each photo object thats placing data into the cells has their height and width data. like so
var adjustedHeight:CFloat? adjustedHeight = Float(view.bounds.width) * photo.standardResolutionImageHeight / photo.standardResolutionImageWidth
Will your solution work for this situation? Looking to dynamically adjust the height of each cell relative to the fixed width of any iOS device for each photo.
Check out my app. www.tipp3d.com to see the collectionview I am talking about.
If I'm understanding correctly the size of your cell depends only on the data's image size. In that case all you need is to have a static function on your cell that returns its size given a photo. Then in collectionView(_:layout:sizeForItemAtIndexPath:) just call that function and return that size.