Swift UITableView长按
let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPressed(sender:)))
table.addGestureRecognizer(longPressRecognizer)
@objc func longPressed(sender: UILongPressGestureRecognizer) {
if sender.state == UIGestureRecognizerState.began {
let touchPoint = sender.location(in: self.table)
if let indexPath = table.indexPathForRow(at: touchPoint) {
print("Long pressed row: \(indexPath.row)")
}
}
}
本文标题:Swift UITableView长按
本文链接:https://www.haomeiwen.com/subject/dyemlftx.html
网友评论