Created
August 7, 2020 07:17
-
-
Save imnaveensharma/ed0268715bb851c7c452c247f8c64626 to your computer and use it in GitHub Desktop.
Add Long Press Gesture Recognizer on Table Cell For Multiple Selection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func setupLongPressGesture() { | |
let longPressGesture:UILongPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.handleLongPress)) | |
longPressGesture.minimumPressDuration = 1.0 // 1 second press | |
//longPressGesture.delegate = self | |
self.tblView.addGestureRecognizer(longPressGesture) | |
} | |
@objc func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) { | |
if gestureRecognizer.state == .began { | |
let touchPoint = gestureRecognizer.location(in: self.tblView) | |
if let indexPath = self.tblView.indexPathForRow(at: touchPoint) { | |
dLog(message: "Selected Cell Index :: \(indexPath.row)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment