Search code examples
objective-ciphoneipadkeyboardresignfirstresponder

IPad dismiss Keyboard without knowing which Textfield opened it


Is there a way to do a general resignFirstResponder to hide the keyboard regardless of what textfield/view/etc calls it?

Reason is I have a lot of textfields on my view and don't want to have to resignFirstResponder for all textfields to hide the keyboard. Just want a general

[self resignFirstResponder].

Any ideas?

Thanks in advance


Solution

  • The easiest way to do this is to have a method for whenever you want to dismiss the keyboard that looks like this:

    -(void)dismissKeyboard {
        [firstField becomeFirstResponder];
        [firstField resignFirstResponder];
    }