Why does this only work sometimes? (UITextView resign first responder question)
Posted
by RexOnRoids
on Stack Overflow
See other posts from Stack Overflow
or by RexOnRoids
Published on 2010-03-28T22:54:00Z
Indexed on
2010/03/29
0:33 UTC
Read the original article
Hit count: 547
When a user presses the "SEND"(return) button I want the keyboard to retract and do other stuff like send a message. But it only works SOMETIMES...
Why does this code only work SOMETIMES? I need it to work all the time obviously, but it doesn't.
- (void)textViewDidChange:(UITextView *)inTextView {
NSString *text = myTextView.text;
if ([text length] > 0 && [text characterAtIndex:[text length] -1] == '\n') {
myTextView.text = [text substringToIndex:[text length] -1];
[myTextView resignFirstResponder];
[self sendMessage];
}
}
© Stack Overflow or respective owner