2016-10-16 4 views
0

ViewControllerUITextFieldDelegate 프로토콜을 구현해보십시오. 나는 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 
    } 

} 
+0

키보드에서 인쇄 할 때 콘솔에 "return"이 인쇄됩니까? – alexburtnik

+0

nope. 아무 일도 일어나지 않는다. – Michael

+0

좋아,'viewDidLoad'가 전혀 호출되지 않았나요? 중단 점 또는 다른'print ("view did load") ' – alexburtnik

답변

0

textField 대리인의 첫 번째 줄을 삭제하려고 할 수 있습니다.

+1

'FUNC textFieldShouldReturn (UITextField에 _에 textField) 나는 이유를 알고 돈 ' – Guan

관련 문제