有没有一种方法可以让iOS的自动更正忽略UITextView中的单个单词或正则表达式? [英] Is there a way to have iOS' autocorrect ignore a single word or regex in a UITextView?
问题描述
我正在构建文本视图来编写状态消息,它的功能之一是在状态消息的文本中包含#hashtags.
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.
但是,这些#hashtags通常不是实际的 words ,因此,一旦输入了井号标签,iOS的自动更正功能会使其带有红色下划线.
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.
(例如:#seafair2014,#wwdc和其他非单词的标签)
(For example: #seafair2014, #wwdc, and other non-word hashtags)
是否可以将术语临时添加到iOS词典中,以忽略任何#hashtag或@username错字,但仍提供其余UITextView
的拼写检查?
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
?
推荐答案
使用+[UITextChecker learnWord:]
.您可以收听更改事件并动态添加标签词.
Use +[UITextChecker learnWord:]
. You can listen to change events and dynamically add hashtag words.
这篇关于有没有一种方法可以让iOS的自动更正忽略UITextView中的单个单词或正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!