ios UICollectionView – 设置自动高度

我正在使用UICollection视图来创build3x4matrix的button。 它在iPhone4中的好看,具有很小的高度。 集合视图也不滚动,因为它在可用空间中显示3x4matrixbutton。
现在,当我在iPHone5上运行相同的应用程序时,我在buttonmatrix下方的底部看到了很多空间。 我想收集视图来增加单元格之间的垂直间距。 有人可以指导我吗?

以math方式制作UICollectionViewFlowLayout,例如:

CGRect mainRect = [[UIScreen mainScreen] bounds]; CGFloat mainWidth = mainRect.size.width; UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; flowLayout.minimumLineSpacing = mainWidth/10; flowLayout.itemSize = CGSizeMake(mainWidth/4, mainWidth/4); 

然后只需分配,因为UICollectionViewFlowLayout:UICollectionViewLayout

 self.collectionView.collectionViewLayout = flowLayout;