apptekstudios / ASCollectionView

A SwiftUI collection view with support for custom layouts, preloading, and more.
MIT License
1.36k stars 160 forks source link

Auto Sizing WaterfallGrid not working (ios 14) #180

Closed luap2703 closed 3 years ago

luap2703 commented 4 years ago

Hey, I tried to use the Waterfall Layout in SwiftUI with images I dont know the aspect ratio or height and so I tried to not provide a WaterfallLayoutDelegate and use the auto layout which is mentioned in the demo. But I always get an error and the app crashes... Am I missing something?

Tianyu95 commented 4 years ago

Do not use ..fitContentSize(dimension: .vertical) and fixedSize(horizontal: false, vertical: true) in iOS14 just a temporary measure

luap2703 commented 4 years ago

so the problem is related to iOS 14? Will there be a fix anytime soon?

Thank you so much for the answer btw!!

apptekstudios commented 3 years ago

For a waterfall layout it is important to know the aspect ratios ahead of time as a single cell changing size can change the layout of every single cell that comes after it. There are techniques to quickly determine size of an image without downloading the whole image (see https://github.com/malcommac/ImageSizeFetcher for some ideas). Alternatively, you could configure your server's API to provide the aspect ratio as part of your fetch request?