Using parameters in action of UITapGestureRecognizer in Swift

前端 未结 5 920
情深已故
情深已故 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:23

    Further to user2277872's response that I also found useful, and just for anyone else who may not be familiar - IBAction functions can also be connected by dragging from the xib to a prewritten function in the class - this is useful if no parameters are desired (i.e. without the : character that was previously mentioned).

    Example with no parameters

    @IBAction private func somethingTapped() {
            ...
    }
    

提交回复
热议问题