Swift – Controlando Teclado iOS
1 de novembro de 2016 | by administrador
//Controlando Teclado iOS - Swift
/*
Primeiro herde a classe "UITextFieldDelegate"
*/
//A classe UITextFieldDelegate, espera que uma view possa delegar
//os eventos herdados, para isso no load, colocamos a referencia
@IBOutlet var textField: UITextField!
@IBOutlet var responseLabel: UILabel!
@IBAction func buttonPressed(sender: AnyObject){
responseLabel.text = textField.text
}
override func viewDidLoad(){
super.viewDidLoad()
self.textField.delegate = self
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?){
self.view.endEditing(true)
}
func textFieldShoulReturn(textField: UITextField!) -> Bool {
textField.resignFirstResponder()
return true
}