This error pops up in the console when tapping return on keyboard(Real device). Everything executes as it should. Keyboard hides but this error keeps on showing in the console.
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
}
}
You need to resign should you return true.
public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With