4

水平设置时UICollectionView滚动的自然方向是从左到右。有什么方法可以扭转这种情况吗?越简单越好。使UICollectionView从右向左滚动?

+0

使用变换:http://stackoverflow.com/questions/25598194/aligning-right-to-left-on-uicollectionview/27560079#27560079 –

回答

9

我不确定你的意思到底是什么 - 如果你将滚动设置为水平,它会同样好,左右滚动。如果你想让它从右侧开始,你可以使用这个方法:

[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:self.theData.count - 1 inSection:0] atScrollPosition:UICollectionViewScrollPositionRight animated:NO]; 

这是假设你有1部,并填充集合视图的数组被称为海图。为迅速

+0

是的,我的道歉因为缺乏澄清,但这就是我的意思 - 因为它从右侧开始而不是从左侧开始,并且让项目安排相同的说法 - 索引0作为第一项。 –

+0

@RobCaraway,如果你想要索引0处的项目出现在右边,作为从右到左格式的第一项,我认为你将不得不颠倒你的数组,或者在cellForItemAtIndexPath方法中,反转参考通过使用(array.count - row -1)而不是行将数据提供给单元格到数组索引。 – rdelmar

1

同一件事:

collectionView?.scrollToItemAtIndexPath(NSIndexPath(forItem: theData.count - 1, inSection: 0), atScrollPosition: .Right, animated: false)