tap gesture recognizer - which object was tapped?

前端 未结 12 1295
萌比男神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:11

    You can also use "shouldReceiveTouch" method of UIGestureRecognizer

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:     (UITouch *)touch {
         UIView *view = touch.view; 
         NSLog(@"%d", view.tag); 
    }    
    

    Dont forget to set delegate of your gesture recognizer.

提交回复
热议问题