在UITapGestureRecognizer上添加参数

时间:2016-05-12 04:03:05

标签: ios swift uilabel uitapgesturerecognizer

我想问一下如何在我的UILabel上的UITapGestureRecognizer上添加一个参数。到目前为止,这就是我得到的:

self.feedSource.text = source_link
                    self.feedSource.userInteractionEnabled = true
                    let feedSourceTapGesture = UITapGestureRecognizer(target: self, action: Selector("openLinkFromFeedSource"))
                    self.feedSource.addGestureRecognizer(feedSourceTapGesture)


func openLinkFromFeedSource() {
        print("tapped")
    }

我想要实现的是当我点击标签时,从openLinkFromFeedSource我可以获得self.feedSource.text的值

谢谢!

2 个答案:

答案 0 :(得分:1)

你应该从这样的轻拍手势动作中得到这个:

func didTapOnView(tap: UITapGestureRecognizer) {
    let label = tap.view
    // do with that label
}

答案 1 :(得分:1)

试试这个

// ...
var dec sql.NullFloat64
row.Scan(&dec)
// dec.Valid - bool
// dec.Float64 - float64