我注意到一个大问题,在从右到左的语言中,单元格的顺序没有正确反转,只有对齐是正确的。但仅适用于水平流布局,并且如果集合视图包含不同的单元格大小!是的,我知道这听起来很疯狂。如果所有单元格大小相同,则排序和对齐良好!
这是我到目前为止使用示例应用程序得到的结果(隔离以确保这是实际问题,而不是其他问题):
这是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)
}