There is a button at bottom right of iPad keyboard which is to hide the keypad.
iPad键盘右下方有一个按钮,用于隐藏键盘。
How can I interact with it programmatically? (get the button then send UIControlEventTouchUpInside
to it).
我如何以编程方式与其进行交互? (获取按钮然后发送UIControlEventTouchUpInside)。
Does anyone know this?
有谁知道这个?
[Edit] In my case, the keyboard is shown on a modal view.
[编辑]在我的情况下,键盘显示在模态视图上。
3 个解决方案
#1
2
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:
覆盖disablesAutomaticKeyboardDismissal以返回NO,如下所示允许您在resignFirstResponder时关闭键盘,即使您的UITextView在模态视图上也是如此。您应该将此代码放入视图控制器,从中启动键盘:
- (BOOL)disablesAutomaticKeyboardDismissal {
return NO;
}
Source: https://*.com/a/6268520
#2
1
In general, you would send the resignFirsResponder
message to the active input view.
通常,您会将resignFirsResponder消息发送到活动的输入视图。
#3
1
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.
我找到了从中得到此代码的地方。它工作正常,但问题是您需要导入私有框架GraphicsServices,这很可能会使您的应用程序被App Store拒绝。
#1
2
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:
覆盖disablesAutomaticKeyboardDismissal以返回NO,如下所示允许您在resignFirstResponder时关闭键盘,即使您的UITextView在模态视图上也是如此。您应该将此代码放入视图控制器,从中启动键盘:
- (BOOL)disablesAutomaticKeyboardDismissal {
return NO;
}
Source: https://*.com/a/6268520
#2
1
In general, you would send the resignFirsResponder
message to the active input view.
通常,您会将resignFirsResponder消息发送到活动的输入视图。
#3
1
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.
我找到了从中得到此代码的地方。它工作正常,但问题是您需要导入私有框架GraphicsServices,这很可能会使您的应用程序被App Store拒绝。