Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide the keyboard programmatically in iphone

How to hide the keyboard programmatically in iphone?

like image 757
thndrkiss Avatar asked Apr 06 '10 17:04

thndrkiss


People also ask

How do I make the keyboard go away on iPhone Swift?

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.

How do you dismiss keyboard when tapping outside textfield?

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.

How do I hide the keyboard in Objective C?

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.


2 Answers

Tell the UIResponder subclass that is currently first responder to resign its first responder status:

[responder resignFirstResponder];
like image 173
glorifiedHacker Avatar answered Oct 21 '22 12:10

glorifiedHacker


[textFieldName resignFirstResponder];
like image 22
Sam Jarman Avatar answered Oct 21 '22 14:10

Sam Jarman