1

Am trying to make a UITextView behave the way the one in Notes does, i.e. you tap to make it editable (turning off the data detectors) then the cursor moves to where you tapped.

Got the tap-to-edit part working with a UITapGestureRecognizer, but how on earth do you translate the tap's CGPoint into a NSRange for moving the cursor?

I don't have the luxury of doing this under 5.0 (no UITextInput for the UITextView, ack). Also needs to be public API's, no private stuff.

Thanks in advance. :)

iHunter
  • 6,205
  • 3
  • 38
  • 56
GB540
  • 121
  • 5

1 Answers1

3
UITextPosition * position=[textView closestPositionToPoint:CGPointMake(20, 20)];
[textView setSelectedTextRange:[textView textRangeFromPosition:position toPosition:position]];
PeakJi
  • 1,547
  • 14
  • 23
  • At the end of a line, this jumps to the next line instead of the end of the selected line. Thoughts on how to fix this? – SAHM Sep 21 '13 at 18:32