Hilaj S L
Hilaj S L

Reputation: 2046

Need to scroll the UICollectionView horizontally automatically with number of collectionViewCell

I have a UICollectionView that scrolls horizontally. And I can create the collectionViewCell programmatically with plus button. The view contains only five collectionViewCell at a time. When I create a new cell, CollectionView needs to scrolls to new created cell. That means i want to see the new created cell with automatic scroll. How can I get it? Please help me

Upvotes: 1

Views: 611

Answers (1)

Bista
Bista

Reputation: 7893

Try this:

NSIndexPath *iPath = [NSIndexPath indexPathForItem:array.count-1 inSection:0];
[self collectionView scrollToItemAtIndexPath:iPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:NO];

Upvotes: 1

Related Questions