gpt4 book ai didi

ios - 在 iOS 9 中你应该使用什么来代替 UICollectionViewFlowLayout AutomaticSize?

转载 作者:行者123 更新时间:2023-11-28 15:10:56 24 4
gpt4 key购买 nike

我有一个带有自定义间隔 flowLayout 的 collectionView。在 iOS 10 及更高版本中,UICollectionViewFlowLayoutAutomaticSize 完美运行。

在 iOS 9 中,使用 estimatedItemSize 会破坏布局,因为布局使用我传递给 estimatedItemSize 的值,即使它们不准确;他们是估计。

单元格的大小根据从服务器返回的内容而变化,因此它们都是不同的。

layout.estimatedItemSize 是在 collectionView 的 super 的 init 中设置的。

如何在 iOS 9 中实现正确的布局行为?

如果我可以澄清,请告诉我!

编辑:对于已接受的答案,我还使用了我想要调整大小的元素的 intrinsicContentSize。

最佳答案

实现以下方法:

- (CGSize)collectionView:(UICollectionView *)collectionView 
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath;

关于ios - 在 iOS 9 中你应该使用什么来代替 UICollectionViewFlowLayout AutomaticSize?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47638047/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com