我想使UILabel可点击。
我已经尝试过了,但是没有用:
class DetailViewController: UIViewController { @IBOutlet weak var tripDetails: UILabel! override func viewDidLoad() { super.viewDidLoad() ... let tap = UITapGestureRecognizer(target: self, action: Selector("tapFunction:")) tripDetails.addGestureRecognizer(tap) } func tapFunction(sender:UITapGestureRecognizer) { print("tap working") } }
你有没有尝试设置isUserInteractionEnabled到true上tripDetails标签?这应该工作。
isUserInteractionEnabled
true
tripDetails