Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed long UITextView's to scroll to the the cursor position instead of the bottom of the UITextView #323

Merged
merged 1 commit into from
Mar 9, 2015

Conversation

DonnaLea
Copy link
Contributor

@DonnaLea DonnaLea commented Mar 9, 2015

In a UITextView with a really long amount of text (think paragraphs) the behaviour of scrolling to the bottom of the text view when the keyboard is shown makes it very difficult to edit text that's at the top or middle of the text view, as the cursor is then off screen. This is especially a problem since when scrolling up to find the cursor the keyboard is dismissed. Please see here for a demonstration of the issue: http://youtu.be/dJRo4eZALOQ (or simply use the Basic Example project and paste a few paragraphs of Lorem Ipsum text into the About section of the registration form).


• Updated the code to do keyboard calculations and scrolling animations on UIKeyboardDidShowNotification instead of UIKeyboardWillShowNotification as the values returned for getting the cursor location weren't correct for where the user had selected in UIKeyboardWillShowNotification.
• Calculating position of cursor to see if the tableview needs scrolling (if it's not covered by the keyboard then there's no need to scroll).
• Makes sure the cursor is at least 3 lines above the keyboard so that there's still some context of the words surrounding the cursor.
• No longer using animation values from the NSNotification since scroll animation is occurring after the keyboard is shown and therefor isn't keeping in synch

nicklockwood added a commit that referenced this pull request Mar 9, 2015
Fixed long UITextView's to scroll to the the cursor position instead of the bottom of the UITextView
@nicklockwood nicklockwood merged commit 9ab7863 into nicklockwood:master Mar 9, 2015
@nicklockwood
Copy link
Owner

Brilliant! Thank you Donna :-)

@TheLittleBoy
Copy link

TheLittleBoy commented May 6, 2016

It has a new problem now. see #448 @DonnaLea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants