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()
    }

Comments

Popular posts from this blog

Windows Keys

how to send invite and give a access of selected application on App Store

how to display popover in TableView cell in swift