How do I use UILongPressGestureRecognizer with a UICollectionViewCell in Swift?
I would like to figure out how to println the indexPath of a UICollectionViewCell when I long press on a cell. How can I do that in Swift? I have looked all over for an example of how to do this; can't find one in Swift. ztan First you your view controller need to be UIGestureRecognizerDelegate . Then add a UILongPressGestureRecognizer to your collectionView in your viewcontroller's viewDidLoad() method class ViewController: UIViewController, UIGestureRecognizerDelegate { override func viewDidLoad() { super.viewDidLoad() let lpgr = UILongPressGestureRecognizer(target: self, action: