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!
Asked
Active
Viewed 6.0k times
92
-
This question is semi-out-of-date; at the time it existed, "Predictive Text" was an ambiguous phrase which often was used loosely to mean auto-correct, but these days that phrase generally refers to the native Predictive Text toolbar that appears above the keyboard. The 8-year-old selected-answer deals with the ambiguous meaning, for those of us in the future, wanting to disable the native predictive text bar the following answer is what you are looking for: https://stackoverflow.com/a/71999199/2057171 — OP I encourage you to update your selected answer as well. – Albert Renshaw Oct 31 '22 at 20:06
8 Answers
193
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)
-
7Careful: `myTextField.autocorrectionType = UITextAutocorrectionTypeNo;` has to be placed before `[myTextField becoreFirstResponder];` to be effective. – Tulleb Oct 29 '14 at 14:52
-
13Does this not disable Auto Correct? The problem here is "Predictive Keyboard Toolbar" being added, but doesn't setting autoCorrection to UITextAutocorrectionTypeNo turn off Auto Correct as well? – daemon Nov 13 '14 at 19:59
-
5My question is the other way: can you disable the autocorrection but keep the word suggestions bar? These are two independent functionalities but seem to be controlled by the same setting, really stupid... – Janneman Feb 03 '17 at 16:11
-
2Damn! i had the same issue as @Janneman, and i was convinced the functionality of "quick type bar" could be combined with "disabling auto correction", since i was seeing this exact behavior on twitter, ig, etc, but no matter what i coded, it would not work on simulator... until i realized that this is a CUSTOMIZATION IN THE USER KEYBOARD SETTINGS (General > Keyboard > Auto-Correction). Just leave it as ```textField.autocorrectionType = .default```, and whether text gets auto corrected will be up to the user, not you, as it should be – Lucas Chwe Feb 13 '19 at 21:05
-
19
Swift 2
textField.autocorrectionType = .Yes
textField.autocorrectionType = .No
Swift 3
textField.autocorrectionType = .yes
textField.autocorrectionType = .no

Andrew
- 3,733
- 1
- 35
- 36
17
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.

Yassine ElBadaoui
- 450
- 7
- 16

Vahagn Gevorgyan
- 2,635
- 19
- 25
8
For me it worked also setting the spellCheckingType as no (iOS 15, Swift 5+)
textField.autocorrectionType = .no
textField.spellCheckingType = .no

Erich Flock
- 227
- 3
- 6
-
3This should be the accepted answer, the others only disable siri auto-correct, they don't disable the predictive text bar like `spellCheckingType` does. Thanks! – Albert Renshaw Oct 31 '22 at 20:05
7
like this you on or off UITextAutocorrectionType
myTextView.autocorrectionType = UITextAutocorrectionTypeNo;
myTextView.autocorrectionType = UITextAutocorrectionTypeYes;

aturan23
- 4,798
- 4
- 28
- 52

Waseem Shah
- 2,219
- 23
- 23
2
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.

DBourne
- 31
- 6