Open sidhenn opened 5 years ago
I need to add a Long Press Gesture to an existing UICollectionView cell in Layout but having problems.
This is the extra code.
extension TimerCollectionViewController: UIGestureRecognizerDelegate { @objc func onDidLongPressTimer(gestureRecognizer : UILongPressGestureRecognizer) { if gestureRecognizer.state != UIGestureRecognizer.State.began { return } let p = gestureRecognizer.location(in: timerCollectionView) if let indexPath = timerCollectionView?.indexPathForItem(at: p) { print("\(indexPath.row) Let's delete this timer.") } else { print("got nothing...") } } }
I also added the following to viewDidLoad()
// Add Long Press Gesture to delete let lpgr : UILongPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(onDidLongPressTimer)) lpgr.minimumPressDuration = 0.5 lpgr.delegate = self lpgr.delaysTouchesBegan = true timerCollectionView?.addGestureRecognizer(lpgr)
Anyone have thoughts on this. Not working using 0.6.35.
Thanks.
I need to add a Long Press Gesture to an existing UICollectionView cell in Layout but having problems.
This is the extra code.
I also added the following to viewDidLoad()