gpt4 book ai didi

ios - 如何使 UILabel 可点击?

转载 作者:IT王子 更新时间:2023-10-29 04:56:00 26 4
gpt4 key购买 nike

我想让 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")
}
}

最佳答案

您是否尝试过将 tripDetails 标签上的 isUserInteractionEnabled 设置为 true?这应该有效。

关于ios - 如何使 UILabel 可点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33658521/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com