Chris
Chris

Reputation: 431

How to swipe left to delete a CollectionCell

I am using a UICollectionView library called VegaScroll. The library is located at https://github.com/ApplikeySolutions/VegaScroll. My question is how can I add a swipe left feature to this, so when the user swipes left, the collection cell shows the trash image and gets deleted? I know its very simple in a table, but I am using this library which is a collection view. I have searched on all the questions on this forum, but they haven't solved this problem. Something like below. I'm also using an XIB for my cell.

enter image description hereThanks all

Upvotes: 4

Views: 8140

Answers (1)

Alexander Nikolaychuk
Alexander Nikolaychuk

Reputation: 664

It is a tableView existed functionality. For collectionView you should write it on your own. There is no existed pre-built solution.

You can use the pod like this (which can what do you need)

https://github.com/SwipeCellKit/SwipeCellKit

Or custom written simple logic like here:

https://medium.com/@ales.musto/using-a-uipangesturerecognizer-to-delete-cells-in-a-uicollectionview-swift-3-e91cdfcce5be

Update: There is actually a way to do this (now) with a built-in API:

How do you support swiping to delete a row in a UICollectionView list with compositional layout?

Upvotes: 4

Related Questions