【发布时间】:2016-02-13 00:21:05
【问题描述】:
我想让 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的框架是什么?你确定你触摸的是标签的框架吗?你有UIViews覆盖标签吗?标签的userInteractionEnabled是否设置为True? -
确保您的 UILabel IBOutlet 已连接到您的 Nib 或 Storyboard
标签: ios swift uilabel uitapgesturerecognizer