2

When entering text into a UITextView, if you type enough lines or hit return enough times, the cursor will naturally go under the keyboard. Certain apps, such as the Apple Notes app, handle this just fine, scrolling the textview until the cursor is visible again. I have struggled to replicate this behavior. I've had no luck with textView.scrollRangeToVisible() with the selectedRange or textView.scrollRectToVisible() with the caret rect.

Some other things I've tried:

Januzellij
  • 177
  • 1
  • 1
  • 10

1 Answers1

-1

I would try the following steps:

  1. Make the UITextView's fill the entire height of the screen

  2. Get the Keyboard Height Dynamically(See: Get the frame of the keyboard dynamically) This is especially important with the release of third party keyboards in iOS 8.

  3. Then when the cursor goes below the keyboard, move the UITextView up by the screen height minus the keyboard height.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
virindh
  • 3,775
  • 3
  • 24
  • 49