Hide keyboard and other when click outside in swift (ios)
@IBOutlet var myTextFiled : UITextFiled!
override func viewDidLoad()
{
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard (_:)))
tapGesture.cancelsTouchesInView = false
self.view.addGestureRecognizer (tapGesture)
}
@objc func dismissKeyboard (_ sender: UITapGestureRecognizer) {
myTextFiled.resignFirstResponder()
}
override func viewDidLoad()
{
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard (_:)))
tapGesture.cancelsTouchesInView = false
self.view.addGestureRecognizer (tapGesture)
}
@objc func dismissKeyboard (_ sender: UITapGestureRecognizer) {
myTextFiled.resignFirstResponder()
}
Comments
Post a Comment