随着 iOS8的发布,我希望在开始输入 UITextField 时禁用键盘的预测文本部分。不知道这是如何做到的,任何帮助将是感激的!
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)
like this you on or off UITextAutocorrectionType
myTextView.autocorrectionType = UITextAutocorrectionTypeNo; myTextView.autocorrectionType = UITextAutocorrectionTypeYes;
FIXED for SWIFT-3:
myTextField.autocorrectionType = .no
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.
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.
For me it worked also setting the spellCheckingType as no (iOS 15, Swift 5+)
textField.autocorrectionType = .no textField.spellCheckingType = .no
if you are using storyboard select your Text Field and under the attributes inspector -
Correction = No Smart Insert = No