我想使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")
}
}
确保您的UILabel IBOutlet已从笔尖或情节提要板中挂接
—
aahrens 2015年
UILabel
?您确定要触摸标签框吗?你有UIViews
覆盖标签吗?被userInteractionEnabled
设置True
为标签?