Disable UITextField Predictive Text

XcodeUitextfieldIos8

Xcode Problem Overview


With the release of iOS 8 I would like to disable the predictive text section of the keyboard when I begin typing in a UITextField. Not sure how this is done, any help would be appreciated!

Xcode Solutions


Solution 1 - Xcode

Setting the autoCorrectionType to UITextAutocorrectionTypeNo did the trick

Objective-C

textField.autocorrectionType = UITextAutocorrectionTypeYes;
textField.autocorrectionType = UITextAutocorrectionTypeNo;

Swift 2

textField.autocorrectionType = .Yes
textField.autocorrectionType = .No

Swift 3

textField.autocorrectionType = .yes
textField.autocorrectionType = .no

SwiftUI

textField.disableAutocorrection(true)
textField.disableAutocorrection(false)

Solution 2 - Xcode

Swift 2

textField.autocorrectionType = .Yes
textField.autocorrectionType = .No

Swift 3

textField.autocorrectionType = .yes
textField.autocorrectionType = .no

Solution 3 - Xcode

The chosen answer is correct, but you also have an option to do the same in storyboard.

All you need is to select your textfield, and under "show the Attributes inspector", set Correction to NO.

See attached image

Solution 4 - Xcode

like this you on or off UITextAutocorrectionType

myTextView.autocorrectionType = UITextAutocorrectionTypeNo;  
myTextView.autocorrectionType = UITextAutocorrectionTypeYes;

Solution 5 - Xcode

Setting autocorrectionType to .no allowed my tableview to scroll to the last entry. With predictive text on the last line was blocked from being selected.

Solution 6 - Xcode

For me it worked also setting the spellCheckingType as no (iOS 15, Swift 5+)

        textField.autocorrectionType = .no
        textField.spellCheckingType = .no

Solution 7 - Xcode

FIXED for SWIFT-3:

myTextField.autocorrectionType = .no

Solution 8 - Xcode

enter image description here

if you are using storyboard select your Text Field and under the attributes inspector -

Correction = No
Smart Insert = No 

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMike SimzView Question on Stackoverflow
Solution 1 - XcodeMike SimzView Answer on Stackoverflow
Solution 2 - XcodeAndrewView Answer on Stackoverflow
Solution 3 - XcodeVahagn GevorgyanView Answer on Stackoverflow
Solution 4 - XcodeWaseem ShahView Answer on Stackoverflow
Solution 5 - XcodeDBourneView Answer on Stackoverflow
Solution 6 - XcodeErich FlockView Answer on Stackoverflow
Solution 7 - XcodeMANISH PATHAKView Answer on Stackoverflow
Solution 8 - XcodeBayCodeView Answer on Stackoverflow