Rob Bonner
Rob Bonner

Reputation: 9426

UITextView not remove keyboard

Question, I have a UITextView in one of my views, but when the user hits the Enter key, the keyboard is removed. I really want the Enter key to put in a \n. This happens in several other places in my app.

Lots of posts to have the return remove the keyboard, but nothing how to keep it.

In the IB, I have the return key type set to Default. Any other settings I need to check into?

Upvotes: 0

Views: 1302

Answers (2)

ans
ans

Reputation: 41

(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
  // end editing and thus hide keyboard
  [textView resignFirstResponder];
  return YES;
}

Upvotes: 0

kennytm
kennytm

Reputation: 523274

Neither UITextView nor UITextField won't remove the keyboard by default. For UITextView that's because the user may really want to enter a line-break. If you want to remove the keyboard you need to write code.

See:

Upvotes: 3

Related Questions