Skip to content

Instantly share code, notes, and snippets.

@dasdom
Last active December 27, 2015 16:29
Show Gist options
  • Save dasdom/7355562 to your computer and use it in GitHub Desktop.
Save dasdom/7355562 to your computer and use it in GitHub Desktop.
Code to move the cursor in a UITextView with a pan.
- (void)panHappend:(UIPanGestureRecognizer*)sender
{
if (sender.state == UIGestureRecognizerStateBegan)
{
self.startRange = self.postTextView.selectedRange;
}
NSRange selectedRange = {MAX(self.startRange.location+(NSInteger)([sender translationInView:self.view].x/8.0f), 0), 0};
self.postTextView.selectedRange = selectedRange;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment