Skip to content

Instantly share code, notes, and snippets.

@kickingvegas
Created October 15, 2012 22:08
Show Gist options
  • Save kickingvegas/3895895 to your computer and use it in GitHub Desktop.
Save kickingvegas/3895895 to your computer and use it in GitHub Desktop.
- (UITextRange *)rangeForWordAtPoint:(CGPoint p) {
UITextPosition *position = [_textView closestPositionToPoint:p];
UITextRange *range =
[_textView rangeEnclosingPosition:position
withGranularity:UITextGranularityWord
inDirection:UITextLayoutDirectionForward];
// UITextStorageDirectionForward, not UITextStorageDirectionRight!
return range;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment