Я пытаюсь реализовать протокол UITextFieldDelegate
в ViewController
. Я начал с apple tutorial. Я реализовал то же самое, что и в учебнике, но он не работает. (XCODE 8)swift 3.0 - расширение UITextFieldDelegate не работает
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
}
}
Является ли «возврат» напечатанным на консоли при печати с клавиатуры? – alexburtnik
nope. ничего не происходит – Michael
Хорошо, вообще называется 'viewDidLoad'? Вы можете проверить его с помощью точки останова или с помощью другого 'print (« view did load »)' – alexburtnik