user523234
user523234

Reputation: 14834

UITextField inside UITextView dimiss Keyboard all at once

I have this setup: A main UIView contains an UITextView that has a UITextField as subview. When I dismiss the the keyboard from the UITextField using resignFirstResponder. The keyboard is dismissed. But it animates back again for the UITextView.

My desired outcome was to dismiss keyboard completely.

I have tried these individually and combination of one or more:

[self endEditing:YES];  // for the main UIView

[myTextView resignFirstResponder];  //UITextView

[myTextField resignFirstResponder];   //UITextField

Edit: As it turned out, it just something that I overlooked. But none seemed to dismiss the keyboard completely.

Any suggestions?

Upvotes: 1

Views: 176

Answers (3)

CEarwood
CEarwood

Reputation: 1685

You could subclass UITextView and override some of the UIResponder methods. Namely canBecomeFirstResponder and return NO when the UITextField was the first responder.

Upvotes: 1

Git.Coach
Git.Coach

Reputation: 3092

Have you tried setting the "firstResponder" to another view? That's how I dismissed the keyboard in those cases.

Upvotes: 1

torip3ng
torip3ng

Reputation: 585

Try this:

[[[UIApplication sharedApplication] keyWindow] endEditing:YES];

Upvotes: 2

Related Questions