iPad "dismiss keyboard" button (lower right), how do I detect when this occurs? What function tells me it was pressed? iPad "dismiss keyboard" button (lower right), how do I detect when this occurs? What function tells me it was pressed? xcode xcode

iPad "dismiss keyboard" button (lower right), how do I detect when this occurs? What function tells me it was pressed?


When the "lower keyboard" button is pressed, the textfield delegate method of:

-(BOOL)textFieldShouldReturn:(UITextField *)textField

Won't be called.

When either the "lower keyboard" or "return button" are pressed, the:

-(void)textFieldDidEndEditing:(UITextField *)textField

Will be called.

I use a variable NSString *lowerKeyboardButtonPressed initially set to @"" which I set to @"N" in the textfieldShouldReturn method ... then in the textFieldDidEndEditing method I check to see if it is set to @"N" ... then I know if the return key or lower keyboard key was pressed. The last line in my textFieldDidEndEditing method sets the variable back to @"".


If you press the keyboard dismiss button and you have a hardware keyboard attached, then the willHide will only be called if you don't have an input accessory view. At which point you need to adjust in the willShow as well (which will have a negative difference between the UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey keys).