0
ViewController
에 UITextFieldDelegate
프로토콜을 구현해보십시오. 나는 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
}
}
키보드에서 인쇄 할 때 콘솔에 "return"이 인쇄됩니까? – alexburtnik
nope. 아무 일도 일어나지 않는다. – Michael
좋아,'viewDidLoad'가 전혀 호출되지 않았나요? 중단 점 또는 다른'print ("view did load") ' – alexburtnik