Hiding UIKeyboard

I am trying to hide the keyboard in my SplitView application (because it covers part of the root menu). However, the only thing I can find is to hide the keyboard after the text field has been used [TextField resignFirstResponder] .

Is there any other way to hide the keyboard?
Ideally, I would like to use barButtonItem, which displays the menu, as a trigger to hide the keyboard.

+6
source share
3 answers

Use this:

 [[[UIApplication sharedApplication] keyWindow] endEditing:YES]; 
+12
source

You need to send the -resignFirstResponder message to an instance of any user interface element that currently has the status of the first responder. Therefore, if your class has the firstNameTextField property corresponding to the UITextField instance, you need to send a message to this object.

[self.firstNameTextField resignFirstResponder];

0
source

resignFirstResponder is a way to do this. If you have a situation where your firstResponder is not configured as an instance variable (possibly generated), you can "get" your first request using this answer . Once you have your first responder object, just step down!

hope this helps.

0
source

Source: https://habr.com/ru/post/922971/


All Articles