4

我注意到一个大问题,在从右到左的语言中,单元格的顺序没有正确反转,只有对齐是正确的。但仅适用于水平流布局,并且如果集合视图包含不同的单元格大小!是的,我知道这听起来很疯狂。如果所有单元格大小相同,则排序和对齐良好!

这是我到目前为止使用示例应用程序得到的结果(隔离以确保这是实际问题,而不是其他问题):

(第一个条形图应始终绘制为蓝色,然后随着索引大小增加。) 在此处输入图像描述

这是UICollectionViewFlowLayout(在 iOS 11 上)的内部错误吗?还是有什么明显的我遗漏的东西?

这是我的测试代码(没什么花哨的 + 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)
}
4

2 回答 2

14

动态大小的 UICollectionViews 上的自动从右到左支持不是受支持的配置。为此,您需要明确注册自动布局镜像,如下所示:

此属性在UICollectionViewLayout(Flow 的父级)上定义,因此您可以在技术上在您已有的任何自定义布局上使用此属性。

于 2018-02-15T01:22:23.327 回答
0

我相信为此,您将必须实现自己的自定义 collectionViewLayout - 尽管我知道人们会期望它会像其他组件的从右到左一样自动工作。

于 2018-01-26T08:00:50.973 回答