how to dismiss keyboard in swift
override func viewDidLoad() {
super.viewDidLoad()
//Looks for single or multiple taps.
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "dismissKeyboard")
//Uncomment the line below if you want the tap not not interfere and cancel other interactions.
//tap.cancelsTouchesInView = false
view.addGestureRecognizer(tap)
}
//Calls this function when the tap is recognized.
@objc func dismissKeyboard() {
//Causes the view (or one of its embedded text fields) to resign the first responder status.
view.endEditing(true)
}
Also in Swift:
- get hours difference between two dates swift
- ionic Library not found for -lGoogleToolboxForMac
- swift file size from url
- receive notificationcenter data in swift
- changing color of background swift
- swift stirng to date
- white or light ASAuthorizationAppleIDButton “Sign in with Apple” button - Swift
- swiftui foreach
- swift initialize a view
- remove padding hstack swiftui
- how to set the stack color in swiftui
- swift add horizontal line uiview programmatically
- swift alert toast
- swift change button text
- variadic parameters swift
- swift convert array to dictionary
- How do I check if a string contains another string in Swift
- for each swiftui
- tableview cell animation swift
- swift generate uuid
- swift comments
- swift for loop index
- swift get day from available string
- activity indicator swiftui