Using parameters in action of UITapGestureRecognizer in Swift

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

    As described in apple developer documents, the action parameter should receive

    action::- A selector that identifies the method implemented by the target to handle the gesture recognized by the receiver. The action selector must conform to the signature described in the class overview. NULL is not a valid value.

    And Valid action method signatures described in UIGestureRecognizer.h are:

    // -(void)handleGesture; // -(void)handleGesture:(UIGestureRecognizer*)gestureRecognizer;

    So basically, you will not be able to send anything else as the parameter except the gestureRecognizer.

提交回复
热议问题