Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to have iOS' autocorrect ignore a single word or regex in a UITextView?

I'm building a textview to compose status messages, and one of the functions it has is to include #hashtags within the text of a status message.

However, these #hashtags often aren't actual words, so iOS' autocorrect functionality causes them to appear with a red underline once the hashtag has been typed.

(For example: #seafair2014, #wwdc, and other non-word hashtags)

Is there a way to temporarily add a term to the iOS dictionary, so as to ignore any #hashtag or @username typos but still provide spell-checking for the rest of the UITextView?

like image 989
bryanjclark Avatar asked Feb 24 '14 18:02

bryanjclark


1 Answers

Use +[UITextChecker learnWord:]. You can listen to change events and dynamically add hashtag words.

Apple Reference

like image 94
Léo Natan Avatar answered Sep 23 '22 10:09

Léo Natan