Im facing issue that is related to scroll to IndexPath after collection view snapshot applied. For this I have write bellow code
dataSource.apply(snapshot, animatingDifferences: false, completion: {
self.scrollToIndex(self.visibleIndex)
})
Unfortunately it is not working for me in < iOS 15
Note: Working for iOS 15 and greater versions
CodePudding user response:
Try performing the scroll operation after a short delay:
dataSource.apply(snapshot, animatingDifferences: false, completion: {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() .milliseconds(10)) {[weak self] in
if let self = self, let indexToScrollTo = self.visibleIndex {
self.scrollToIndex(indexToScrollTo)
}
}
})
CodePudding user response:
You can Use this
self.collectionView.scrollToItem(at:IndexPath(item: index, section: 0), at: .right, animated: false)