I have the following code to hide my keyboard when the user taps the view, but touchesBegan is not firing at all:
class LoginViewController: UIViewController, UITextFieldDelegate {
@IBOutlet var emailAddress: UITextField
@IBOutlet var password: UITextField
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//Delegate fields
self.emailAddress.delegate = self
self.password.delegate = self
}
override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
self.emailAddress.resignFirstResponder()
self.password.resignFirstResponder()
}
func textFieldShouldReturn(textField: UITextField!) -> Bool{
self.emailAddress.resignFirstResponder()
self.password.resignFirstResponder()
return true;
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
This view controller is inside of a navigation controller, so not sure if it has something to do with the responder chain