Daniel M. Daniel M. - 9 months ago 15
iOS Question

iOS SDK: Dismiss keyboard when a button gets clicked?

How can I dismiss the keyboard when the user clicks a button?
A short example for a better understanding: the user edits some text in some textfields and at the end he doesn't click "Done" or smething else on the keyboard, but he clicks on an button "Save" while the keyboard is still shown. So, how can I now dismiss the keyboard?

Thx. Regards, Daniel


in button action write,

if([textField isFirstResponder]){
  [textField resignFirstResponder];

if there are more textfields get the current textfield reference everytime while editing started, and resign its responder in button action.