美文网首页
Swift UITableView长按

Swift UITableView长按

作者: AppMonkey | 来源:发表于2018-04-26 17:37 被阅读0次
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