Skip to content

Instantly share code, notes, and snippets.

@keicoder
Forked from troyharris/gist:6877536
Last active August 29, 2015 13:56
Show Gist options
  • Save keicoder/9181595 to your computer and use it in GitHub Desktop.
Save keicoder/9181595 to your computer and use it in GitHub Desktop.
objective-c : UITextView - 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