【问题标题】:Hide iOS Keyboard Predictive Text Bar - UITextView / UITextField隐藏 iOS 键盘预测文本栏 - UITextView / UITextField
【发布时间】:2022-01-10 07:43:36
【问题描述】:

好像设置

autocorrectionType = UITextAutocorrectionTypeNo;

对于 UITextViewUITextField 不再足以隐藏 iOS 键盘的预测栏。

Apple 是否决定这只能由用户在键盘设置中隐藏?或者这还有一些方法可以以编程方式做到这一点?我们需要为包含拼写练习的应用执行此操作。

【问题讨论】:

    标签: ios xcode keyboard uitextfield uitextview


    【解决方案1】:

    这会为我移除预测文本栏:

    @IBOutlet var tf: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        tf.autocorrectionType = .no
        tf.spellCheckingType = .no
    }
    

    【讨论】:

    • 所以你需要子类来实现这个?
    • 不只是在 UITextField 之外创建出口
    • @Peter - 不,不需要子类化。该代码只是通过代码将两个属性设置为.no 的示例。如果您已在 Storyboard 中添加了文本字段并希望在其中执行此操作,请在“属性检查器”窗格中将 CorrectionSpell Checking 设置为 No
    • 忘记设置 spellCheckingType = UITextSpellCheckingTypeNo。现在工作。谢谢。
    猜你喜欢
    • 2015-01-17
    • 1970-01-01
    • 1970-01-01
    • 2012-07-16
    • 1970-01-01
    • 1970-01-01
    • 2013-06-25
    • 2021-01-05
    • 2015-02-22
    相关资源
    最近更新 更多