I have one UITextview in which user enter text. after that i take that text as a string and display it开发者_如何学Go in another textview and want the words which are grammatically incorrect.
How to do that?
Use the UITextChecker class that's been available since ios 3.2: Apple Documentation
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.
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
You can use Correction option under Text Input Traits in TextField
Attributes using Interface Builder. It will take care of Valid English words.
精彩评论