简体   繁体   中英

UITextView, with spell checking, how to use `ignoreWord`?

Regarding the spell checking in iOS, it's possible to tell the checker to ignore a word (or learn a word),

https://developer.apple.com/documentation/uikit/uitextchecker

func ignoreWord(String)
Tells the receiver to ignore the specified word when spell-checking.
- Apple doco

Say I have a UITextView which opens. I want spell checking On.

I know the user may type "fattie" which would get the red underline.

How do I tell that text view in that instance, to, ignore "fattie" ?

An obvious use case ...

User is typing in "@tag" type friends; in our data of course we know what all the tags are, it's absurd they get marked as spelling errors.

It seems incredible one can't just say "don't underline these words - - list".

Code example ....

So we have

var t: UITextView

and then, there must be "some way" to:

yourTextView.something->something.textChecker.ignoreWord("fattie"

.. some way to get to the text view's textChecker instance! How ?!?!

Partial answer: I just stumbled on to that, bizarrely, you can just call

    UITextChecker.learnWord("fattie")
    UITextChecker.learnWord("blahdee")

from, apparently, just anywhere in an app.

However this raises many issues,

• How to call the 'ignore' one, which seems better

• That one still makes the user tap the annoying, stupid, "in quotes" OK box in the suggestions bar - it seems to have not really "learned" anything

• Disturbingly, I think this goes for the "WHOLE PHONE". I only want it in that instance of the user using that text view.

A mystery!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM