Search code examples
iosobjective-cuitextviewuitextviewdelegate

textView resignFirstResponder not firing UIKeyboardWillHideNotification


I have a UIView which contains UITexView and a Button. I have a delegate UITextViewDelegate.

When I first set the cursor on the UITextView, the delegate function "textViewShouldEndEditing" gets called, and this function triggers the UIKeyboardWillShowNotification notification. So far so good.

When I click on the button, I call the function [self.textView resignFirstResponder];, this function then calls the delegate "textViewShouldEndEditing", but the notification UIKeyboardWillHideNotification never gets called.

I have a listener for the notification

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(_keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];

Is there anything missing ???


Solution

  • [self.view endEditing:YES]; is the trick, Thank you all for your help