Skip to content

Instantly share code, notes, and snippets.

@andreconghau
Created October 15, 2020 01:33
Show Gist options
  • Save andreconghau/45d93fef8d9c7a21f4593193ae9be27c to your computer and use it in GitHub Desktop.
Save andreconghau/45d93fef8d9c7a21f4593193ae9be27c to your computer and use it in GitHub Desktop.
can not called seletedAt after apply hideKeyboard when touch outside
extension UIViewController {
public func hideKeyboarOnTap() {
let tap = UITapGestureRecognizer(target: self, action: #selector(hideKeyboardAction))
tap.cancelsTouchesInView = false
self.view.addGestureRecognizer(tap)
}
@objc private func hideKeyboardAction() {
self.view.endEditing(true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment