作者:玩玩r28g | 来源:互联网 | 2022-12-30 20:14
我注意到一个很大的问题,在从右到左的语言中,单元格顺序没有正确反转,只有对齐是正确的.但仅适用于水平流布局,如果集合视图包含不同的单元格大小!是的,我知道这听起来很疯狂.如果所有单元格大小相同,则排序和对齐方式都很好!
以下是我到目前为止使用示例应用程序(隔离以确保这是实际问题,而不是其他内容):
(第一个柱应始终绘制为蓝色,然后使用索引增加尺寸.)
这是UICollectionViewFlowLayout
(在iOS 11上)的内部错误吗?或者有什么明显的东西我不见了?
这是我的测试代码(Nothing fancy + XIB with UICollectionView
):
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 6
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "test", for: indexPath)
cell.backgroundColor = (indexPath.item == 0) ? UIColor.blue : UIColor.red
return cell
}
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: (10 * indexPath.item) + 20, height: 170)
}
wakachamo..
11
动态大小的UICollectionViews上的自动从右向左支持不是受支持的配置.为此,您需要明确注册自动布局镜像,如下所示:
创建一个子类 UICollectionViewFlowLayout
覆盖flipsHorizontallyInOppositeLayoutDirection
,并true
在Swift或YES
Objective-C中返回
将其设置为集合视图的布局
此属性在UICollectionViewLayout
(Flow的父级)上定义,因此您可以在已有的任何自定义布局上使用此属性.
1> wakachamo..:
动态大小的UICollectionViews上的自动从右向左支持不是受支持的配置.为此,您需要明确注册自动布局镜像,如下所示:
创建一个子类 UICollectionViewFlowLayout
覆盖flipsHorizontallyInOppositeLayoutDirection
,并true
在Swift或YES
Objective-C中返回
将其设置为集合视图的布局
此属性在UICollectionViewLayout
(Flow的父级)上定义,因此您可以在已有的任何自定义布局上使用此属性.