0
我有UILabel
一個子類,看起來像這樣:UIGestureRecognizer中的UILabel子類不會被調用
class GestureLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
initialize()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
initialize()
}
func initialize() {
self.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: Selector("longPressGestureRecognizer:")))
}
deinit {
gestureRecognizers?.removeAll()
}
func longPressGestureRecognizer(sender: AnyObject) {
print("this is never called")
}
}
但longPressGestureRecognizer
永遠不會被調用。難道我做錯了什麼?
我認爲這是很好的提'userInteractionEnabled'是'默認爲'UILabel' FALSE'。 – Eendje
是的,工作,我不能相信我忘了;) – Daniel