Search code examples
objective-ciphonecocoa-touchuiscrollviewuicollectionview

Make UICollectionView scroll right to left?


The natural direction for a UICollectionView to scroll when set horizontally is from left to right. Is there any way to reverse this? The simpler the better.


Solution

  • I'm not sure exactly what you mean -- if you set the scrolling to horizontal, it scrolls equally well, left and right. If you want it to start it from the right side, you can use this method:

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

    This assumes that you have 1 section, and the array populating the collection view is called theData.