问题
Why collectionview with flow layout sometimes not showing cells, but delegate ask for size, and section items count and responder give correct information.
Here example, trouble with 6 section
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
As u can see in numberOfItemsInSection (ASKED, RETUR) returned 1 item in 6 section
2015-04-08 04:43:59.044 RETUR SECTION:6 ITEMS:1
After that in sizeForItemAtIndexPath for 0 item in 6 section returned size
2015-04-08 04:43:59.053 SIZE_ SECTION:6 ITEM:0 SIZE:320x80
But then collectionview ask for cell, not called for section 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
回答1:
I found solution!
2015-04-08 04:43:59.053 SIZE_ SECTION:2 ITEM:0 SIZE:320x0
If u see what yours cell disappears where they must be visible, check your sizes!
If any of border size will be a zero, it's broke correct working CollectionViewFlowLayout.
来源:https://stackoverflow.com/questions/29504487/why-uicollectionview-with-uicollectionviewflowlayout-not-show-cells-but-ask-for