Reputation: 23
I've been searching on google for that , but didn't found any answer.
I want to use TouchesBegan but on a specific object, like a textview, a label, ... I've tried to replace "any object" by the pointer of my object but it doesn't work.
Is there on other way to detect the touch on a object with a method , in witch I can tell after : do something ? , like in the touchesbegan method but for a specific object ?
Thank you in advance for your answers / or sample code would be great ;o)
Have a nice day ! Robin
Upvotes: 2
Views: 915
Reputation: 901
Make CGRect
by CGRectMake()
on that area and then check, if touch is within that area - then do your things.
// sample code inside Touchesbegan method
CGRect tempRect = CGRectMake(x, y, width, height);
if (CGRectContainsPoint(tempRect, touchlocation))
{
// do some thing
}
Upvotes: 2
Reputation: 961
I'm not sure I understand exactly what you're asking, but if you subclass the class of object you want to detect touches on and add a touchesBegan method to that class, it will only get triggered when the object it belongs to is touched. Which I believe is what you're looking for.
Or are you asking something different? Howard
Upvotes: 0