I\'m using the below code to detect words tapped in a UITextView. This works fine, but I want to detect some special characters, like a ?
. ?
doesn\
This code worked for me on iOS 6:
- (void)tappedTextView:(UITapGestureRecognizer *)recognizer {
UITextView *textView = (UITextView *)recognizer.view;
CGPoint location = [recognizer locationInView:textView];
UITextPosition *tapPosition = [textView closestPositionToPoint:location];
UITextRange *textRange = [textView.tokenizer rangeEnclosingPosition:tapPosition withGranularity:UITextGranularityCharacter inDirection:UITextLayoutDirectionRight];
NSString *character = [textView textInRange:textRange];
NSLog(@"%@", character);
}