【发布时间】:2015-11-26 11:18:36
【问题描述】:
在我的应用程序中,我使用 UICollectionView 来列出产品。要求是有条件地设置单元格的高度。我使用以下代码。
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout*)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
{
if (indexPath.row == 3 || indexPath.row == 6 || indexPath.row == 7 || indexPath.row == 10 || indexPath.row == 0)
{
return CGSizeMake((collectionView.frame.size.width/2)-4, 300.0);
}
return CGSizeMake((collectionView.frame.size.width/2)-4, 250.0);
}
通过,此代码完全设置单元格的高度,但水平单元格没有像图像一样正确设置。我想删除垂直单元格之间的额外空间。我将单元格和线条的最小间距设置为距故事板边缘 8 像素。
【问题讨论】:
-
@VirajPadsala 我需要 Objective-c 并且没有约束。
标签: ios objective-c iphone uicollectionview uicollectionviewcell