Skip to content

Instantly share code, notes, and snippets.

@troyharris
Created October 8, 2013 00:33
Show Gist options
  • Save troyharris/6877536 to your computer and use it in GitHub Desktop.
Save troyharris/6877536 to your computer and use it in GitHub Desktop.
A very hacky way to enable UITextView to scroll to the cursor when typing. I believe I got this from someone on SO but I can't find the original source anymore
- (void)textViewDidChange:(UITextView *)textView {
[self _showTextViewCaretPosition:textView];
}
- (void)textViewDidChangeSelection:(UITextView *)textView {
[self _showTextViewCaretPosition:textView];
}
- (void)_showTextViewCaretPosition:(UITextView *)textView {
CGRect caretRect = [textView caretRectForPosition:self.lyricsText.selectedTextRange.end];
[textView scrollRectToVisible:caretRect animated:NO];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment