Browse Source

hide keyboard on tap to remove focus from UITextView

cyberta 5 years ago
parent
commit
e2f28b83eb

+ 1 - 0
deltachat-ios/Controller/NewGroupController.swift

@@ -60,6 +60,7 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
         doneButton.isEnabled = false
         tableView.register(ContactCell.self, forCellReuseIdentifier: "contactCell")
         tableView.register(ActionCell.self, forCellReuseIdentifier: "actionCell")
+        self.hideKeyboardOnTap() 
     }
 
     override func viewWillAppear(_ animated: Bool) {

+ 12 - 0
deltachat-ios/Extensions/Extensions.swift

@@ -45,3 +45,15 @@ extension URLSession {
         return (data, response, error)
     }
 }
+
+extension UIViewController {
+    func hideKeyboardOnTap() {
+        let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard))
+        tap.cancelsTouchesInView = false
+        view.addGestureRecognizer(tap)
+    }
+
+    @objc func dismissKeyboard() {
+        view.endEditing(true)
+    }
+}