gpt4 book ai didi

ios - 查看<(空):0x0> does not conform to UITextInput protocol when tapping Return button on keyboard

转载 作者:行者123 更新时间:2023-12-04 12:00:18 24 4
gpt4 key购买 nike

在键盘(真实设备)上点击返回时,控制台中会弹出此错误。一切都按原样执行。键盘隐藏,但此错误一直显示在控制台中。

import UIKit

class ViewController: UIViewController, UITextFieldDelegate {

lazy var nameTextField: UITextField = {
let textField = UITextField()
textField.placeholder = "Name:"
textField.delegate = self
return textField
}()

lazy var surnameTextField: UITextField = {
let textField = UITextField()
textField.placeholder = "Surname:"
textField.delegate = self
return textField
}()

override func viewDidLoad() {
super.viewDidLoad()

view.addSubview(nameTextField)
view.addSubview(surnameTextField)

}

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
view.endEditing(true)
return true
}


}

最佳答案

如果你回来,你需要辞职 .

    public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}

关于ios - 查看<(空):0x0> does not conform to UITextInput protocol when tapping Return button on keyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65194532/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com