Using parameters in action of UITapGestureRecognizer in Swift

前端 未结 5 935
情深已故
情深已故 2021-02-04 04:00

I am trying to call a function with parameters using the action of UITapGestureRecognizer and I can\'t figure out any alternative.

This here is the gesture

5条回答
  •  名媛妹妹
    2021-02-04 04:14

    All you need to do is call it without using any kind of parameters in your string literal.

    var gestureDoubleTap = UITapGestureRecognizer(target: self, action: "doubleTap:")
    

    The : tells the computer that you're using a function with a parameter, and that is created somewhere else.

    Hope this helps :)

提交回复
热议问题