The goal is to handle swipes on UICollectionView cells. Each swipe left should present a delete option for the cell upon which the swipe occurred.
The current implementation attaches a swipe gesture recognizer to the UICollectionView then checks for the cell as follows:
let swipeGesture = UISwipeGestureRecognizer(target: self, action: #selector(cellSwiped))
swipeGesture.direction = .Left
collectionView.addGestureRecognizer(swipeGesture)
func cellSwiped(gestureRecognizer : UISwipeGestureRecognizer) {
let point = gestureRecognizer.locationInView(collectionView)
if let indexPath = collectionView.indexPathForItemAtPoint(point) {
// Do stuff
}
}
The alternative is to customize the UICollectionViewCell to handle swipes.
What are the pros/cons of each? Are both equally good?