我的UICollectionView有两个问题:
minimumInteritemSpacing
不起作用
它在iOS 6上水平溢出
我设置了这样的布局:
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize = CGSizeMake(70.0f, 70.0f); layout.scrollDirection = UICollectionViewScrollDirectionVertical; layout.minimumLineSpacing = 0.0f; layout.minimumInteritemSpacing = 0.0f; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; // I set the size of _collectionView in layoutSubviews: // _collectionView.frame = self.bounds; _collectionView.contentInset = UIEdgeInsetsMake(8.0f, 8.0f, 8.0f, 8.0f);
图像在iOS 6上显示结果(在iOS 7上没有溢出,但列之间的间距仍然不为零)
我试过这个解决方案https://gist.github.com/OliverLetterer/5583087,但在我的情况下它并没有解决任何问题.
从minimumInterItemSpacing
物业的文件:
对于水平滚动网格,此值表示同一列中项目之间的最小间距.该间距用于计算单个行中可以容纳的项目数,但是在确定项目数量之后,可以向上调整实际间距.
流动布局将在整个宽度上均匀地间隔单元格,间距不小于您设置的最小值.如果您不想要间距,则需要实现自己的布局.
iOS 6溢出问题我不确定.尝试删除对iOS 6的支持;)