I try implement UITextFieldDelegate
protocol in ViewController
. I have started with apple tutorial. I implemented the same such as it is on tutorial but it doesn't work. (XCODE 8)
class ViewController: UIViewController, UITextFieldDelegate {
// MARK: Properties
@IBOutlet weak var recipeNameField: UITextField!
@IBOutlet weak var recipeNameLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
recipeNameField.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: Actions
@IBAction func onSetDefaultRecipeClick(_ sender: UIButton) {
recipeNameField.text = "Deafult recipe name"
}
// MARK: UITextFieldDelegate
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
print("return")
return true
}
}