Reputation: 2046
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
Reputation: 7893
Try this:
NSIndexPath *iPath = [NSIndexPath indexPathForItem:array.count-1 inSection:0];
[self collectionView scrollToItemAtIndexPath:iPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:NO];
Upvotes: 1