xcode 禁用 UITextField 预测文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25767522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:58:28  来源:igfitidea点击:

Disable UITextField Predictive Text

xcodeuitextfieldios8

提问by Mike Simz

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!

随着 iOS 8 的发布,我想在开始输入 UITextField 时禁用键盘的预测文本部分。不知道这是如何完成的,任何帮助将不胜感激!

回答by Mike Simz

Setting the autoCorrectionType to UITextAutocorrectionTypeNo did the trick

将 autoCorrectionType 设置为 UITextAutocorrectionTypeNo 就行了

Objective-C

目标-C

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

Swift 2

斯威夫特 2

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

Swift 3

斯威夫特 3

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

回答by Andy

Swift 2

斯威夫特 2

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

Swift 3

斯威夫特 3

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

回答by Vahagn Gevorgyan

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.

您只需要选择您的文本字段,然后在“显示属性检查器”下,将更正设置为NO

See attached image

见附件图片

回答by Waseem Shah

like this you on or off UITextAutocorrectionType

像这样你打开或关闭 UITextAutocorrectionType

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

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

回答by DBourne

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.

将 autocorrectionType 设置为 .no 允许我的 tableview 滚动到最后一个条目。最后一行的预测文本被阻止被选中。

回答by MANISH PATHAK

FIXED for SWIFT-3:

已修复 SWIFT-3:

myTextField.autocorrectionType = .no

回答by Budhabhooshan Patil

Tap and hold the language key (the one that looks like a globe or possibly an Emoji smile face) and set the toggle for "Predictive" to off.

点击并按住语言键(看起来像地球仪或可能是表情符号笑脸的那个)并将“预测”的切换设置为关闭。