1

我目前正在研究应用程序,其中我需要UICollectionview的动态单元大小类似于hooked story appDynamic Cell如何创建UICollectioview Cell动态大小像上瘾的应用程序

上图中展示我need.I与其他自定义库,如 试图WaterfallCollectionViewMosaicLayoutFMMosaicLayoutgreedo-layout

使用的CollectionView委托方法

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return [self sizeForPhotoAtIndexPath:indexPath]; 
} 

-(CGSize)sizeForPhotoAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UIImage *image = [imageArray objectAtIndex:indexPath.row]; 
    return CGSizeMake(image.size.width, image.size.height); 
} 

但我的照片,从API负载,我无法预测图像加载之前该单元格的大小。 所以请帮助我这个。谢谢你提前。

+0

我真的不看到你的形象实际上是在你的代码 – MNM

+0

检查现在,我添加的代码图像 –

+0

你正在从服务器我想不会从那里加载图像,大概这取决于'imageViews'模式'看点配合'等等。 – vaibhav

回答

0

跟踪索引路径上的图像是否被下载。如果下载的话返回下载的图片大小,否则返回一些静态图片高度或者直接返回CGSizeZero。下载图片时不要忘记重新加载单元格。这一切我可以建议你提供了什么信息。

相关问题