使用节的UICollectionView在单元格之间留下间隙 [英] UICollectionView using sections leaves a gap between cells

查看:184
本文介绍了使用节的UICollectionView在单元格之间留下间隙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UICollectionView来显示几个数据部分。这些部分具有固定数量的项目。我希望所有项目都以连续网格显示。

I'm using a UICollectionView to show several sections of data. These sections have a fixed number of items. I want all the items to show in a continuous grid.

现在我在水平方向完成此任务:

Right now I accomplish this in horizontal orientation:

但在纵向上这留下了很大的差距:

But in vertical this leaves a big gap:

我想解决这个差距部分,因为它是丑陋的,它不属于那里。
我很乐意使用自定义的FlowLayout,但是我找不到一个指向正确方向的教程(我找到了几个,但没有一个真正触及这个问题。)

I want to solve this gap between sections because it's ugly and it doesn't belong there. I'd be happy to use a custom FlowLayout, but I can't find a tutorial that points me in the right direction (I've found several, but none of them really touch this problem specifically.)

任何人都可以帮我解决这个问题,或者至少指出我正确的方向吗?

Can anybody help me solve this problem, or at least point me in the right direction?

PS:我已经实现了部分,因为我正在加载数据。目前使用1部分不适合我。

P.S: I've implemented sections because I'm loading the data on the fly. Using 1 section isn't an option for me at this moment.

更新
根据要求我添加使用的值对于我当前的FlowLayout。我在全屏(减去UINavigationBar)UICollectionView上使用标准水平流布局,每个部分有21个项目。

UPDATE On request I'm adding the values used for my current FlowLayout. I'm using the standard Horizontal Flow Layout on a fullscreen (minus UINavigationBar) UICollectionView with 21 items per section.


  • 滚动方向:水平

  • 单元大小:248,196

  • 页眉/页脚大小:无

  • 单元格的最小间距:10

  • 行的最小间距:10

  • 部分插入:20,20,10,10

  • Scroll direction: Horizontal
  • Cell size: 248, 196
  • Header / footer size: none
  • Min spacing for cells: 10
  • Min spacing for lines: 10
  • Section Insets: 20, 20, 10, 10

推荐答案

像这样使用

它将解决差距问题

UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];

layout.minimumInteritemSpacing = 0;
layout.minimumLineSpacing = 2;

这篇关于使用节的UICollectionView在单元格之间留下间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆