How do you create a “Swipe-to-delete” for a cell in a UICollectionView?
(simular to tableViews)
You could add a UIGesture like:
let UpSwipe = UISwipeGestureRecognizer(target: self, action: someMethod: )
UpSwipe.direction = UISwipeGestureRecognizerDirection.Up
cell.addGestureRecognizer(UpSwipe)
in the cellForRowAtIndexPath and then in that someMethod do:
func someMethod(sender: UISwipeGestureRecognizer) {
let cell = sender.view as! UICollectionViewCell
let itemIndex = self.collectionView.indexPathForCell(cell)!.item
yourArray.removeAtIndex(itemIndex)
self.collectionView.reloadData()
}