I’ve a view with 10 character labels (big letters). Each character (label) has a different tag. The functionality that I’m developing is “Trace”.
When user moves his finger over the view, i want to detect which character is touched.
I think I’ve to implement,
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
But I’m not knowing how to identify touch on the label and identify the character.
Can some one help me?
If you want to know the view that the touch began on (which view the user put their finger down on), you can read any of the touch items returned in the
NSSetlike so:However, even as the finger moves across the screen, this
viewproperty will ONLY return the view initially touched and not the view currently under the finger. To do this, you will need to track the coordinates of the current touch and determine which view it falls into, perhaps like this:The key to success on this is to make sure that you are getting your touches in coordinates reference to the proper views, so make sure to call
locationInView:andCGRectContainsPoint()appropriately with values that match your application’s view hierarchy and where your placing this code (i.e. the View, ViewController, etc.)