[英]Change the flow layout of a UICollectionView
Based on filter results, I need to change the flow layout of a collection view and reload the data using a different kind of cell.根据过滤结果,我需要更改集合视图的流布局并使用不同类型的单元格重新加载数据。 However you can't just do this:但是,您不能只这样做:
myCollectionView.flowLayout = ...
So how is it possible to change the flow layout of a collection view?那么如何改变集合视图的流布局呢?
SHORT AND SIMPLE ANSWER简短而简单的答案
You can access/set the flowLayout like this:您可以像这样访问/设置 flowLayout:
collectionView.collectionViewLayout = ...
LONG ANSWER长答案
You said:你说:
However you can't just do this:但是,您不能只这样做:
myCollectionView.flowLayout = ...
But in fact you can set the collection view's collectionViewLayout
, and it does just what you want:但实际上你可以设置集合视图的collectionViewLayout
,它会做你想做的事:
Assigning a new layout object to this property causes the new layout to be applied ... to the collection view's items.将新布局对象分配给此属性会导致将新布局应用于...集合视图的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.