添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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!

You can use the following property:

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

As defined in the UITextInputTraits protocol here

You can turn off auto correction by

textField.autocorrectionType = UITextAutocorrectionTypeNo;

and can turn on by

textField.autocorrectionType = UITextAutocorrectionTypeYes;

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;

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.