How to hide the keyboard programmatically in iphone?
Via Tap Gesture This is the quickest way to implement keyboard dismissal. Just set a Tap gesture on the main View and hook that gesture with a function which calls view. endEditing . Causes the view (or one of its embedded text fields) to resign the first responder status.
To make the keyboard go away itself, we need to remove “focus” from all of our text fields (if your app has more than one text field) by calling the unfocus() method: FocusManager. instance.
You can force the currently-editing view to resign its first responder status with [view endEditing:YES] . This hides the keyboard. Unlike -[UIResponder resignFirstResponder] , -[UIView endEditing:] will search through subviews to find the current first responder. So you can send it to your top-level view (e.g. self.
Tell the UIResponder subclass that is currently first responder to resign its first responder status:
[responder resignFirstResponder];
[textFieldName resignFirstResponder];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With