tap gesture recognizer - which object was tapped?

前端 未结 12 1282
萌比男神i
萌比男神i 2020-12-29 17:47

I\'m new to gesture recognizers so maybe this question sounds silly: I\'m assigning tap gesture recognizers to a bunch of UIViews. In the method is it possible to find out w

12条回答
  •  天涯浪人
    2020-12-29 18:14

    You should amend creation of the gesture recogniser to accept parameter (add colon ':')

    UITapGestureRecognizer *letterTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(highlightLetter:)];
    

    And in your method highlightLetter: you can access the view attached to recogniser:

    -(IBAction) highlightLetter:(UITapGestureRecognizer*)recognizer
    {
        UIView *view = [recognizer view];
    }
    

提交回复
热议问题