How to attach different UIGestureRecognizer(s) to *different* parts of the same UITextView
I want to attach different UIGestureRecognizer(s) to the same UITextView on different parts of the text.
E.g., "I am awesome and you are too", when user taps on "I am awesome" the app would do something and when user taps on "you are too" the app would do something else.
Is it possible to do that? (note: break them into 2 strings is not a solution sin开发者_运维知识库ce it could be wrapped around)
Thanks!
A couple solutions spring to mind:
If you are using UILabels to display the strings, you could enable user interaction on the labels and add seperate gesture recognizers to each label.
Alternately, you could have one gesture recognizer and in the method to handle the gesture, figure out where the touch was (if it is a tap gesture recognizer, you can use locationInView:
to, well get its location in a given view). Then, when you determine what was touched,
精彩评论