blog address: http://findnerd.com/list/view/How-to-detect-tapped-word-in-UItextview/771
keywords: Uitextview,Tapping,Tapped Word
member since: Dec 15, 2015 | Viewed: 59
How to detect tapped word in UItextview
Category: Academics
download We might face a situation when we need to add action on tapping a particular word from a string on the iPhone screen like a link or a hashtag etc. Now though we can easily add a UITapGestureRecognizer on a UITextView or UILabel, finding the exact tapped word is tricky. Here is how to do this (using UITextView and UILongPressGestureRecognizer) : i) Add gesture recognizer to text view UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressResponse:)]; [textViewDescription addGestureRecognizer:longPress]; ii) Handle gesture recognizer - (void)longPressResponse:(UILongPressGestureRecognizer *)recognizer { if (recognizer.state == UIGestureRecognizerStateBegan) { CGPoint location = [recognizer locationInView:textViewDescription]; NSString *tappedWord = [self wordAtPosition:CGPointMake(location.x, location.y)]; http://findnerd.com/list/view/How-to-detect-tapped-word-in-UItextview/771
{ More Related Blogs }
Academics
SCB99...
Jan 7, 2024
Academics
Python Training Institute in S...
Sep 19, 2021
Academics
Best College in Mysuru...
May 3, 2022
Academics
Discover Dubai: 10-Hour Full D...
Sep 23, 2024
Academics
Managing Your Local Git Reposi...
Sep 20, 2021
Academics
Corporate Training providers i...
Sep 20, 2021