How to programmatically turn off Auto Correction in iphone sdk?

10,536

Solution 1

You can use the following property:

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

As defined in the UITextInputTraits protocol here

Solution 2

You can turn off auto correction by

textField.autocorrectionType = UITextAutocorrectionTypeNo;

and can turn on by

textField.autocorrectionType = UITextAutocorrectionTypeYes;

Solution 3

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;

Solution 4

textField.autocorrectionType = UITextAutocorrectionTypeNo;

Solution 5

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.

Share:
10,536
meetpd
Author by

meetpd

I am the CEO of Upnexo Technologies Pvt. Ltd. We are a Product and Content Development Company. Our list of sites include: Upnexo.com HalfPantHippo.com TopVPN.Review SplitScreenApp.com ReviewRoller.com

Updated on June 14, 2022

Comments

  • meetpd
    meetpd almost 2 years

    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!