Created
October 8, 2013 00:33
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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