1

I have a UITextView which I call resignFirstResponder on when the return key is hit. The text view does resign first responder (the flashing cursor thing in the text box goes away), but the keyboard sometimes won't go away.

What could be causing this problem?

Thank you!

Ayaka Nonaka
  • 856
  • 1
  • 10
  • 22
  • you may need to show some code for us to diagnose further – Sheehan Alam Aug 09 '10 at 04:45
  • All I really have is a method that gets called that calls [userName resignFirstResponder], where userName is a UITextView linked with IB. I know the method gets called because I have a print statement there that prints, and the cursor goes away. Thanks. – Ayaka Nonaka Aug 09 '10 at 04:50
  • I'm saw this same problem on an app I'm working on. So has BiteSMS: http://forums.bitesms.com/forums/1/topics/3858. I can't reproduce it though. I'm not sure how it happened or how to fix it. Did you ever find out? – ma11hew28 May 25 '11 at 17:56

1 Answers1

1

Declare the UITextViewDelegate protocol

Then implement this

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
 if([text isEqualToString:@"\n"])
{
        [textView resignFirstResponder];
        return NO;
}

    return YES;
}
raaz
  • 12,410
  • 22
  • 64
  • 81