12

Possible Duplicate:
iPhone Programming: Deactivate spell check in UITextView

I am creating a spelling quiz app.

When I type in text in textbox, because auto-correction is ON it shows the correct answer.

I would like to do either of following: (a) Programatically turn OFF Auto-Correction OR (b) Give user the option to manually turn OFF Auto-Correction within the app.

Please let me know solution to either of above.

Thanks!

Community
  • 1
  • 1
meetpd
  • 9,150
  • 21
  • 71
  • 119

5 Answers5

25

You can use the following property:

myTextField.autocorrectionType = UITextAutocorrectionTypeNo; //in ios 8 use UITextAutocorrectionTypeNo.

As defined in the UITextInputTraits protocol here

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
3

You can turn off auto correction by

textField.autocorrectionType = UITextAutocorrectionTypeNo;

and can turn on by

textField.autocorrectionType = UITextAutocorrectionTypeYes;
Neo
  • 936
  • 6
  • 17
2
textField.autocorrectionType = UITextAutocorrectionTypeNo;
MD SHAHIDUL ISLAM
  • 14,325
  • 6
  • 82
  • 89
Apurv
  • 17,116
  • 8
  • 51
  • 67
2

For a UITextField you can set the 'Correction' to YES or NO through Interface Builder/Storyboard (near Capitalization and Keyboard Type), to set it programatically you can use:

UITextField *yourTextField;
yourTextField.autocorrectionType = UITextAutocorrectionTypeNo;
Nathan Dries
  • 1,015
  • 8
  • 20
1

UITextView and UITextField both implement the UITextInputTraits protocol. As such, they both have a property autocorrectionType, which is itself of type UITextAutocorrectionType. The default value for this property is on. You can set it to be UITextAutocorrectiontypeNo in your code (probably when you create the view), which will disable any autocorrection.

Peter
  • 1,349
  • 11
  • 21