Disable Scribble in UITextView

There are use cases where someone who's using an Apple Pencil may not want to enter text via Scribble. A simple example is writing "UIViewController" in a text view is unlikely to be successful.

I'd like to disable Scribble in this case and let the keyboard become the input mechanism. (Disabling Scribble system-wide in Settings is both cumbersome and overkill.)

The closest I can come to making this happen is by adding a UIScribbleInteraction on a UITextView and returning false when scribbleInteraction(shouldBeginAt:) is called.

This disables Scribble on the text view, and prevents writing from being converted into text, but the input widget still appears on screen and isn't very useful.

Here is a sample project that demonstrates the problem:

http://files.iconfactory.net/craig/bugs/Scribbler.zip

Hopefully, I'm doing something wrong here. If not, I'm happy to submit this as a FB.

-ch

Replies

Adding a UIScribbleInteraction on a UITextView and returning false for scribbleInteraction(_:shouldBeginAt:) seems to be the official way to do this. To prevent the input widget from showing up you can set UITextView.inputView. If you do not want any view to show up you can specify an empty UIView via setting textView.inputView = UIView().

Returning false for the beginning of the interaction does disable Scribble, but does not prevent the widget from appearing.

Setting the inputView to nil has no effect, the widget still appears instead of the keyboard. Since there is no public way to get the user's preferred keyboard view, I don't see how this approach can work.

-ch