I'm really bangin' my head because I can't find the way to show the soft keyboard when there's a bluetooth input device connected to the iPad. I made some search on the web and this is the result:
- a question on stackoverflow with a very short answer How can I detect if an external keyboard is present on an iPad?
- an application developed by erica sadun for the cydia env http://www.tuaw.com/2010/06/02/hacksugar-bringing-back-the-on-screen-keyboard/
Erica said that the trick is to answer to the system that "There's no hardware keyboard attached". I tried to write a category for UIKeyboardImpl and I overrided:
- (BOOL)isInHardwareKeyboardMode {
DEBUG(@"is called");
return NO;
}
But until now I haven't obtained anything. The overrided method is called but there's no soft keyboard. Erica also said the application works by dynamic linking but I don't know how can I accomplish it. I don't need to be in the AppStore because this is a private application so I don't bother about rejection.
Thanks in advance
Ok. Finally got it. Many thanks to David, Matthias and Enrico. Here are the steps:
- import the private framework GraphicsServices
- call GSEventSetHardwareKeyboardAttached(NO) inside the viewDidLoad
add a button that toggles the keyboard by calling
static void toggleKeyboard(UIKeyboardImpl * keyImpl){ if (UIKeyboardAutomaticIsOnScreen()) { UIKeyboardOrderOutAutomatic(); } else { UIKeyboardOrderInAutomatic(); }
I've found this function on http://code.google.com/p/btstack/wiki/iPhoneKeyboardHiding Now I can take input from the soft keyboard and from the bluetooth device at the same time.
To get around it using the apple keyboard you hit the eject key. Perhaps you can implement an action that sends the eject keycode? I think iSSH has a feature where you can tap the onscreen keyboard icon to bring it up even when a bluetooth keyboard is connected.
来源:https://stackoverflow.com/questions/4150724/display-soft-keyboard-ipad-when-is-connected-a-bluetooth-input-device