I'm trying to use UICollectionView to make a table, when I set it to vertical scroll, everything is working great. But when I set it to horizontal scroll, it appears some additional line spacing: https://i.stack.imgur.com/7536O.jpg
我正在尝试使用UICollectionView来创建一个表,当我将它设置为垂直滚动时,一切都运行良好。但当我将其设置为水平滚动时,它会显示一些额外的行间距:https://i.stack.imgur.com/7536O.jpg
And this is what it working on vertical scroll(no spacing): https://i.stack.imgur.com/AxFMy.jpg
这就是它在垂直滚动(无间距)上的工作:https://i.stack.imgur.com/AxFMy.jpg
Following is some setting about my Collection View:
以下是关于我的集合视图的一些设置:
i.stack.imgur.com/aWGO3.jpg
i.stack.imgur.com/vrbLp.jpg
Is there any way to solve this? Thanks!
有什么方法可以解决这个问题吗?谢谢!
(Sorry for I can't post image and can't post more than 2 links, because it need more than 10 reputation..)
(抱歉,我无法发布图片,不能发布超过2个链接,因为它需要超过10个声誉..)
2 个解决方案
#1
1
Your collection cell height is 80 and Screen height is 480 I guess, and there are 5 items showing vertically so remaining space(480-(80*5)) which is 80 is showing between items as 20 pixels. So you should either increase your cell size or adjust size of UICollecttionView
.
您的收集单元格高度为80,屏幕高度为480我猜,并且有5个项目垂直显示,因此剩余空间(480-(80 * 5))80表示项目之间为20像素。因此,您应该增加单元格大小或调整UICollecttionView的大小。
#2
0
try this :
尝试这个 :
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
returnn 0
}
#1
1
Your collection cell height is 80 and Screen height is 480 I guess, and there are 5 items showing vertically so remaining space(480-(80*5)) which is 80 is showing between items as 20 pixels. So you should either increase your cell size or adjust size of UICollecttionView
.
您的收集单元格高度为80,屏幕高度为480我猜,并且有5个项目垂直显示,因此剩余空间(480-(80 * 5))80表示项目之间为20像素。因此,您应该增加单元格大小或调整UICollecttionView的大小。
#2
0
try this :
尝试这个 :
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
returnn 0
}