答案 0 :(得分:0)
确保您将userInteractionEnabled设置为true
在您的viewDidLoad
YOUR_Label.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(self.uilabelTapped(_:)))
YOUR_Label.addGestureRecognizer(tap)
在您的ViewController中
@objc func uilabelTapped(_ sender: UITapGestureRecognizer) {
print("UILabel Tapped")
}
确保您的tableView和uilabel是同一视图的子视图
希望这对您有帮助