iOS Text Input Traits and How to Stop Quicktype aka Predictive Text From Adding a Space?

1.5k views Asked by At

In iOS 11 (11.0.3 to be exact), a space gets added when a person taps on the word offered by QuickType aka Predictive Text.

You can see the "Michael" being offered: Michael offered

Here it shows the space character that was inserted after the Michael was tapped (Xs added just to show the space): enter image description here

My Interface Builder settings on the field look like the following: Text Input Traits of Given Name

Using Text Input Traits only, how do I keep the space from getting added when a word is selected using QuickType aka Predictive Text? I tried setting UITextSmartInsertDeleteType to no and that works for paste. However, it does not work for QuickType / Predictive Text.

Here is the smartInsertDeleteType documentation. In the Apple forums, I only found this related conversation: Re: Predictive Text Bug?

Since we have validation on the fields that we want to use QuickType on (email addresses, phone numbers, and so on), it's not good enough to just trim off the space after the fact.

I already know about textField(_:shouldChangeCharactersIn:replacementString:) and hope I don't have to deal with it there.

0

There are 0 answers