Predictive Text Bug?

When setting the content type for UITextFields I get really nice predictive suggestions for forms. However, all of these have a space at the end when they are touched. So in my function to check the legality of the character(s) entered, I have to add a space as a legal character list which is silly for zip codes, phone numbers, urls and email addresses. Is there a way to catch the predictive touch string and clean it up before placing its value in the text field? For instance the zip code content should be "43560" NOT "43560 ". That way I can avoid spaces if a user decides to type it in.

Replies

Maybe you could find something here :

h ttps://developer.apple.com/documentation/uikit/uitextinputtraits/2865828-smartinsertdeletetype



try to set

optional var smartInsertDeleteType: UITextSmartInsertDeleteType { get set }

to no.


Edited

I tried with no success, either programmatically or in IB.


What you could investigate:

- intercept key pressed

- find out what is the event when you hit a predictive key

- act on this event by deleteing the end space

I tried as well, I did find that method. I can't find how to intercept the accessory view touch...

I assume it is IOS ? Or OSX with smart function keys ?


Does that mean that hitting the predictive keys on the keyboard does not generate a key pressed event ?

I also have this problem, and that smartInsertDeleteType property also did not work for me.

I'm having to write ridiculous situation-specific code to find spaces and decide to remove them or not, because our users usually can't see the trailing spaces, and we sometimes enable our final buttons based on whether the inputs have valid format.