Reputation: 1635
How can I turn off auto correct and spell check in Swift? I found the following for objective-c, but nothing so simple for swift.
myTextView.autocorrectionType = UITextAutocorrectionTypeNo;
Upvotes: 27
Views: 16664
Reputation: 78
With swift 4.2: TextView and TextField
textView.autocorrectionType = .no
textField.autocorrectionType = .no
Upvotes: 3
Reputation: 1635
I'm answering all my own questions today... This seems to work.
textView.autocorrectionType = .no
Upvotes: 55
Reputation: 139
With regards to the line of code that you posted, simply swap out the myTextField
with the name of the field you wish to disable autocorrect functionality for, then after the = sign, just add .No
Upvotes: 0
Reputation: 2269
To make more sense of this when coming from Obj-C to Swift and why you can do .No
instead of UITextAutocorrectionTypeNo
, you can also do this:
myTextView.autocorrectionType = UITextAutocorrectionType.No
Upvotes: 1