2014-09-10 22 views
54

Mit der Veröffentlichung von iOS 8 möchte ich den vorhersagenden Textabschnitt der Tastatur deaktivieren, wenn ich anfange, ein UITextField einzugeben. Nicht sicher, wie das gemacht wird, jede Hilfe wäre willkommen!Disable UITextField Predictive Text

Antwort

137

die autoCorrectionType zu UITextAutocorrectionTypeNo Einstellung hat den 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 
+0

Sie sollten dies als die richtige Antwort markieren. – DanM

+6

Vorsicht: 'myTextField.autocorrectionType = UITextAutocorrectionTypeNo;' muss vor '[myTextField becoreFirstResponder];' platziert werden, um effektiv zu sein. – Tulleb

+8

Wird die automatische Korrektur nicht deaktiviert? Das Problem hier ist "Predictive Keyboard Toolbar" hinzugefügt wird, aber nicht AutoCorrection auf UITextAutocorrectionTypeNo deaktivieren auch Auto Correct? – daemon

4

wie diese Sie auf o R off UITextAutocorrectionType

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

+5

Gibt es eine Möglichkeit, dies zu tun, aber die automatische korrekte Funktionalität zu behalten? – mumush

13

Swift 2

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

Swift 3

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

FIXED für SWIFT-3:

myTextField.autocorrectionType = .no 
0

Tippen Sie auf den Sprachenschlüssel (der wie ein Globus oder möglicherweise ein Emoji-Smile-Gesicht aussieht) und halten Sie ihn gedrückt, und deaktivieren Sie den Schalter für Predictive.

1

Die gewählte Antwort ist korrekt, aber Sie haben auch die Möglichkeit, das gleiche im Storyboard zu tun.

Alles, was Sie brauchen, ist Ihr Textfeld auszuwählen und unter "Show the Attributes Inspector" Korrektur auf NO setzen. Überprüfen Sie das angehängte Bild.

See attached image

Verwandte Themen