Of course people reported these issues in PSPDFKit as well, so I had to find a workaround. I’m usingcontentInset when the keyboard (iPhone) or another view (iPhone/iPad) goes up, which is pretty much completely ignored by UITextView in iOS 7. This is most frustrating since it works perfectly in iOS 6.

At first my solution was based on a category, but after discovering more and more needed hooks, I moved over to a subclass that automatically forwards all delegate methods. This has the advantage of more shared code, and we might be able to remove all those horrible hacks once iOS 8 comes out. I certainly hope so and will write a few more radars.

So, what’s fixed in PSPDFTextView?

When adding a newline, UITextView will now properly scroll down. Previously, you needed to add at least one character for this to happen.

Scrolling to the caret position now considers contentInset. UITextView completely ignored this.

Typing will also consider contentInset and will update the scroll position accordingly.

Pasted text will scroll to the caret position.

To enable these fixes, simply use PSPDFTextView instead of UITextView:

This is working quite well for my use case, but there surely are edge cases where this won’t be enough (like when using rich text). I also tried using the new textContainerInset but this didn’t work as intended and didn’t solve my scrolling problems.

I have to give credit to countless people that searched for the same solution – this very much was a community oriented fix. Sadly, this doesn’t seem to be a priority for Apple, since it’s still broken in iOS 7.1b3.

Please fork the repo and send a pull request, if you have any ideas how to simplify the code or find an even better workaround.