how identify touch in a particular view

Kumar sonu picture Kumar sonu · Mar 4, 2011 · Viewed 8.9k times · Source

How to get touch on a particular view.

I am using

CGPoint Location = [[touches anyObject] locationInView:self.view ];

but want to trigger the action only if an particular subView is clicked.
How to do this.

Answer

Kumar sonu picture Kumar sonu · Mar 4, 2011

I got the answer myself...but thanks other which helped me on this

here it is

UITouch *touch ;
touch = [[event allTouches] anyObject];


    if ([touch view] == necessarySubView)
{
//Do what ever you want
}