Долгое нажатие на ячейку cell tableView (Long press for cell) - Swift 5
override func
viewDidLoad() {
super.
viewDidLoad()
let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPress(longPressGestureRecognizer:)))
tableView.
addGestureRecognizer(
longPressRecognizer)
}
@objc func longPress(longPressGestureRecognizer: UILongPressGestureRecognizer) {
if longPressGestureRecognizer.state == UIGestureRecognizer.State.began {
let touchPoint = longPressGestureRecognizer.location(in: self.view)
if let indexPath = tableView.indexPathForRow(at: touchPoint) {
print("longPress: \(indexPath.row)")
}}
}
Возврат к списку