0

为什么带有流布局的collectionview有时不显示单元格,但委托要求大小,部分项目计数和响应者提供正确的信息。

这里的例子,6段的麻烦

2015-04-08 04:43:59.020 ASKED SECTION:0 ITEMS:0
2015-04-08 04:43:59.023 RETUR SECTION:0 ITEMS:1
2015-04-08 04:43:59.023 ASKED SECTION:1 ITEMS:0
2015-04-08 04:43:59.024 RETUR SECTION:1 ITEMS:1
2015-04-08 04:43:59.024 ASKED SECTION:2 ITEMS:0
2015-04-08 04:43:59.024 RETUR SECTION:2 ITEMS:1
2015-04-08 04:43:59.024 ASKED SECTION:3 ITEMS:0
2015-04-08 04:43:59.024 RETUR SECTION:3 ITEMS:1
2015-04-08 04:43:59.025 ASKED SECTION:4 ITEMS:0
2015-04-08 04:43:59.043 RETUR SECTION:4 ITEMS:0
2015-04-08 04:43:59.043 ASKED SECTION:5 ITEMS:0
2015-04-08 04:43:59.043 RETUR SECTION:5 ITEMS:0
**2015-04-08 04:43:59.043 ASKED SECTION:6 ITEMS:0**
**2015-04-08 04:43:59.044 RETUR SECTION:6 ITEMS:1**
2015-04-08 04:43:59.044 ASKED SECTION:7 ITEMS:0
2015-04-08 04:43:59.044 RETUR SECTION:7 ITEMS:8
2015-04-08 04:43:59.045 ASKED SECTION:8 ITEMS:0
2015-04-08 04:43:59.046 RETUR SECTION:8 ITEMS:0
2015-04-08 04:43:59.046 ASKED SECTION:9 ITEMS:0
2015-04-08 04:43:59.046 RETUR SECTION:9 ITEMS:2
2015-04-08 04:43:59.049 SIZE_ SECTION:0 ITEM:0 SIZE:320x70
2015-04-08 04:43:59.052 SIZE_ SECTION:1 ITEM:0 SIZE:320x70
2015-04-08 04:43:59.053 SIZE_ SECTION:2 ITEM:0 SIZE:320x0
2015-04-08 04:43:59.053 SIZE_ SECTION:3 ITEM:0 SIZE:320x246.1538
**2015-04-08 04:43:59.053 SIZE_ SECTION:6 ITEM:0 SIZE:320x80**
2015-04-08 04:43:59.055 SIZE_ SECTION:7 ITEM:0 SIZE:320x139
2015-04-08 04:43:59.057 SIZE_ SECTION:7 ITEM:1 SIZE:320x139
2015-04-08 04:43:59.062 SIZE_ SECTION:7 ITEM:2 SIZE:320x79
2015-04-08 04:43:59.066 SIZE_ SECTION:7 ITEM:3 SIZE:320x79
2015-04-08 04:43:59.069 SIZE_ SECTION:7 ITEM:4 SIZE:320x79
2015-04-08 04:43:59.072 SIZE_ SECTION:7 ITEM:5 SIZE:320x79
2015-04-08 04:43:59.075 SIZE_ SECTION:7 ITEM:6 SIZE:320x79
2015-04-08 04:43:59.079 SIZE_ SECTION:7 ITEM:7 SIZE:320x79
2015-04-08 04:43:59.079 SIZE_ SECTION:9 ITEM:0 SIZE:139x139
2015-04-08 04:43:59.080 SIZE_ SECTION:9 ITEM:1 SIZE:139x139
2015-04-08 04:43:59.082 CELL_ SECTION:0 ITEMS:0
2015-04-08 04:43:59.087 CELL_ SECTION:1 ITEMS:0

正如您在 numberOfItemsInSection (ASKED, RETUR) 中看到的那样,在 6 部分中返回了 1 项

2015-04-08 04:43:59.044 返回部分:6 项目:1

之后在 sizeForItemAtIndexPath 中为 6 部分中的 0 项返回大小

2015-04-08 04:43:59.053 尺寸_部分:6 项目:0 尺寸:320x80

但是然后collectionview要求单元格,而不是第6节

2015-04-08 04:43:59.082 CELL_ SECTION:0 ITEMS:0
2015-04-08 04:43:59.087 CELL_ SECTION:1 ITEMS:0
4

1 回答 1

0

我找到了解决方案!

2015-04-08 04:43:59.053 SIZE_ SECTION:2 ITEM:0 SIZE:320x0

如果您看到您的单元格在必须可见的地方消失了,请检查您的尺寸!

如果任何边框大小为零,则说明 CollectionViewFlowLayout 无法正常工作。

于 2015-04-08T02:33:21.263 回答