【问题标题】:Swift: UITextInput protocol does not conformSwift:UITextInput 协议不符合
【发布时间】:2021-03-12 22:11:26
【问题描述】:

所以我有一个登录屏幕,它可以工作,但是我的调试器在输入过程中一遍又一遍地抛出相同的错误,我不知道为什么会这样。

[Assert] View <(null):0x0> does not conform to UITextInput protocol

这是我的代码

let emailTextField: UITextField = {
    let textField = UITextField()
    textField.placeholder = "emailaddress".localized
    textField.translatesAutoresizingMaskIntoConstraints = false
    textField.backgroundColor = .white
    textField.font = UIFont.init(name: "AlegreyaSans-Regular", size: 18)
    textField.autocapitalizationType = .none
    textField.textContentType = .emailAddress
    textField.keyboardType = .emailAddress
    let paddingView: UIView = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: 20))
    textField.leftView = paddingView
    textField.leftViewMode = .always
    return textField
}()

渲染正常,工作正常,但是打字时错误堆积如山。

【问题讨论】:

标签: ios swift iphone


【解决方案1】:

不确定这是否对您有帮助,但当我试图让我的键盘在用户点击返回时隐藏时,我遇到了一个比喻问题。我所做的是将 textField 的委托发送给 textField.delegate = self

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多