how to pass argument for gesture selector

前端 未结 1 1947
青春惊慌失措
青春惊慌失措 2021-01-28 16:06

I added a gesture to a label and when tapped i would like to trigger showlbl that will take int as an argument, however I\'m getting a compiler error for:

UITapG         


        
相关标签:
1条回答
  • 2021-01-28 16:13

    It doesn't work that way. You can only specify the name of the selector, i.e. the name of the method that is to be called. The form of the selector (the number of arguments) is fixed and defined by the class that calls your action method (in this case, UITapGestureRecognizer).

    For this particular action method, the one and only argument to the action method will be an object of type UIGestureRecognizer *). If you the method to have access to another variable, you have to declare an appropriate ivar/property and store the value there.

    0 讨论(0)
提交回复
热议问题