I have a UITextView
. I implemented a navigationBar UIBarButtonItem
to respond to a touch and resign the firstResponder for my UITextView
.
But, when the selector method is called, the keyboard doesn't get dismissed. I checked the UITextView's responder status with isFirstResponder
and it returns YES. I also checked it with canResignFirstResponder
and the return value is NO.
I must be missing something here...why is it returning NO?
I get that I can override canResignFirstResponder
by subclassing UITextView, but I'd like to avoid that if possible.
Here's a code snippet:
- (void) commentCancelButtonTouched:(id)sender
{
NSLog(@"Cancel button touched");
[self.navigationBar popNavigationItemAnimated: NO];
if ([self.textInput.textView canResignFirstResponder] == NO) {
NSLog(@"I don't want to resign!");
}
[self.textInput.textView resignFirstResponder];
}