Naresh
Naresh

Reputation: 363

How to find which object we are touching using tapgesture

I have so many UIview objects on self.view and one tap gesture is also available on self.view. Now my concern is when ever i touch the self.view i would like to know under my touch any UIView object is there or not if s i want to get the properties of that object like tag value. Please help me how to get information.Thanks in advance.

Upvotes: 0

Views: 51

Answers (1)

matt
matt

Reputation: 534977

You might like to read my book on this topic:

http://www.apeth.com/iOSBook/ch18.html#_hit_testing

Example code from that section:

CGPoint p = [g locationOfTouch:0 inView:self]; // g is the gesture recognizer
UIView* v = [self hitTest:p withEvent:nil];

Where self is the superview to which the gesture recognizer is attached. You'll need to make the necessary substitutions...

Upvotes: 1

Related Questions