From 6fcd6a52e2596af830b01a581d8a2a23cb5155e9 Mon Sep 17 00:00:00 2001 From: James Wardle Date: Mon, 9 Jan 2017 22:01:02 +0000 Subject: [PATCH] Update InfiniteCollectionView.swift + Added selectItem override to allow programatic selection of items - previously this was not considered and broken. --- InfiniteCollectionView/InfiniteCollectionView.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/InfiniteCollectionView/InfiniteCollectionView.swift b/InfiniteCollectionView/InfiniteCollectionView.swift index a2f6248..01769d2 100644 --- a/InfiniteCollectionView/InfiniteCollectionView.swift +++ b/InfiniteCollectionView/InfiniteCollectionView.swift @@ -50,6 +50,10 @@ open class InfiniteCollectionView: UICollectionView { open func rotate(_ notification: Notification) { setContentOffset(CGPoint(x: CGFloat(pageIndex + indexOffset) * itemWidth, y: contentOffset.y), animated: false) } + open override func selectItem(at indexPath: IndexPath?, animated: Bool, scrollPosition: UICollectionViewScrollPosition) { + let updatedIndexPath = IndexPath(row: correctedIndex(indexPath!.item + indexOffset), section: 0); + super.selectItem(at: updatedIndexPath, animated: animated, scrollPosition: scrollPosition); + } } // MARK: - private