Close the IOS keyboard when clicking confirm

2

How do I make the keyboard add when I click on a button to confirm the name in the textbox?

I want when I click on the confirm button the player adds the keyboard, because it keeps appearing cutting the half of the screen where the game is

    
asked by anonymous 22.01.2016 / 14:42

1 answer

1

As you do not press the keyboard return in the field, you do not have the textField in which the event occurred. So you have to say that view is no longer being edited, as follows:

self.view.endEditing(true)

Another way to do this, when you know the field that was edited (usually when you have only one on the screen you can do this) would be:

txtName.resignFirstResponder()

Where txtName is the name of your textField .

    
22.01.2016 / 15:00