How to check spelling entered in textview?

走远了吗. 提交于 2019-12-08 02:56:40

问题


I have one UITextview in which user enter text. after that i take that text as a string and display it in another textview and want the words which are grammatically incorrect.

How to do that?


回答1:


iOS system only provide spell checking while the user is inputting text. If the user choose to type in the wrong word or words, iOS cannot help. If you want to perform your own spell checking, you will have to include your own spell checking library.

GNU Aspell is a Free and Open Source spell checker designed to eventually replace Ispell. It can either be used as a library or as an independent spell checker.

Aspell Spell Checker on iPhone? was asked a few years ago here on SO. I am not sure if they ever got it working.




回答2:


Use the UITextChecker class that's been available since ios 3.2: Apple Documentation




回答3:


Use autocorrectionType property of UITextInputTraits protocol which is implemented by UITextView

@property(nonatomic) UITextAutocorrectionType autocorrectionType

Use it as below

To disable

myTxtview.autocorrectionType = UITextAutocorrectionTypeNo;

To enable

myTxtview.autocorrectionType = UITextAutocorrectionTypeYes;

In Apple Documentation




回答4:


You can use Correction option under Text Input Traits in TextField Attributes using Interface Builder. It will take care of Valid English words.



来源:https://stackoverflow.com/questions/5675128/how-to-check-spelling-entered-in-textview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!