Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: Nigel Smith
Added: Dec 18, 2017 9:20 PM
Modified: Dec 18, 2017 9:20 PM
Views: 29
Tags: no tags
  1.  
  2.     // Set up a tap gesture to remove the keyboard when tapped outside
  3.     private func registerForTapDismissal() {
  4.         guard let delegate = controller else {
  5.             notify.send(Notification.error(message: "Keyboard delegate must be provided."))
  6.             return
  7.         }
  8.  
  9.         let tap = UITapGestureRecognizer(target: self, action: #selector(KeyboardService.dismissKeyboard))
  10.         tap.cancelsTouchesInView = false
  11.         delegate.view.addGestureRecognizer(tap)
  12.     }
  13.