Can't resignFirstResponder with UITextView
Posted
by Calvin L
on Stack Overflow
See other posts from Stack Overflow
or by Calvin L
Published on 2010-06-03T05:47:13Z
Indexed on
2010/06/03
19:54 UTC
Read the original article
Hit count: 369
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];
}
© Stack Overflow or respective owner