I would like to have a paged UICollectionView
, with each page displaying cells from left to right. What I can achieve now with classic UICollectionViewFlowLayout
and
我想有一个分页的UICollectionView,每个页面从左到右显示单元格。我现在用经典的UICollectionViewFlowLayout和
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
The result is the following :
结果如下:
page 1 page 2
cell 1 | cell 3 || cell 5 | cell 7
cell 2 | cell 4 || cell 6 | cell 8
What I would like to achieve now is:
我现在想要达到的目标是:
page 1 page 2
cell 1 | cell 2 || cell 5 | cell 6
cell 3 | cell 4 || cell 7 | cell 8
I would like to know if there is simpler solution than creating my own flow controller ? Or if not, is there some place where I can see the source code for UICollectionViewFlowLayout
which is not so different of what I want ?
我想知道是否有比创建自己的流量控制器更简单的解决方案?或者如果没有,是否有一些地方可以看到UICollectionViewFlowLayout的源代码,这与我想要的不同?
1 个解决方案
#1
10
I finally made my own layout subclassing UICollectionViewFlowLayout : I replace each cell's collectionViewAttributes with the corresponding one if it was a classic collectionViewFlowLayout, using a little bit of maths.
我最终创建了自己的布局子类化UICollectionViewFlowLayout:如果它是一个经典的collectionViewFlowLayout,我使用一些数学替换每个单元格的collectionView属性与相应的一个。
It now fits my needs, and could be useful for someone else, so here is my code: https://github.com/philippeauriach/fullyhorizontalcollectionview
它现在符合我的需要,可能对其他人有用,所以这是我的代码:https://github.com/philippeauriach/fullyhorizontalcollectionview
#1
10
I finally made my own layout subclassing UICollectionViewFlowLayout : I replace each cell's collectionViewAttributes with the corresponding one if it was a classic collectionViewFlowLayout, using a little bit of maths.
我最终创建了自己的布局子类化UICollectionViewFlowLayout:如果它是一个经典的collectionViewFlowLayout,我使用一些数学替换每个单元格的collectionView属性与相应的一个。
It now fits my needs, and could be useful for someone else, so here is my code: https://github.com/philippeauriach/fullyhorizontalcollectionview
它现在符合我的需要,可能对其他人有用,所以这是我的代码:https://github.com/philippeauriach/fullyhorizontalcollectionview