Reputation: 1227
I am using a collection to delete a item I am just deleting an item from datasource and then reloading the CollectionView. on deleting the cell collection adjust its scroll position. This is happening without animation. I want the CollectionView to adjust scroll position with animation. How to do that ?
Upvotes: 2
Views: 421
Reputation: 2220
Following code snippet may help you
Get your current indexPath and delete row from below code may solve your problem
yourCollectionView.deleteItems(at: [indexPath!])
Note : No need to reload your CollectionView
Upvotes: 1
Reputation: 115
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
self.collectionView.scrollToItem(at: IndexPath, atScrollPosition: .centeredHorizontally, animated: true)
}
Upvotes: 1
Reputation: 657
you try that code
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
self.images.removeObject(at: indexPath.item)
self.collectionView.reloadData()
}
Upvotes: 0