Reputation: 3491
There is a button at bottom right of iPad keyboard which is to hide the keypad.
How can I interact with it programmatically? (get the button then send UIControlEventTouchUpInside
to it).
Does anyone know this?
[Edit] In my case, the keyboard is shown on a modal view.
Upvotes: 8
Views: 2751
Reputation: 21
Overriding disablesAutomaticKeyboardDismissal
to return NO
as below allows you to dismiss the keyboard when you resignFirstResponder
, even when your UITextView
is on a modal view. You should put this code to your view controller, from which you initiate the keyboard:
- (BOOL)disablesAutomaticKeyboardDismissal {
return NO;
}
Source: https://stackoverflow.com/a/6268520
Upvotes: 2
Reputation: 7303
Something like this? I can't remember where I found this code but I used it to toggle the on-screen keyboard because it would be hidden by default if a bluetooth one was connected.
- (void) toggleKeyboard(UIKeyboardImpl * keyImpl){
if (UIKeyboardAutomaticIsOnScreen()) {
UIKeyboardOrderOutAutomatic();
} else {
UIKeyboardOrderInAutomatic();
}
Edit
I found where I got this code from. It works fine but the catch is that you need to import the private framework GraphicsServices
, which would most likely get your app rejected from the App store.
Upvotes: 1
Reputation: 19251
In general, you would send the resignFirsResponder
message to the active input view.
Upvotes: 1