问题
I'm attempting to build a Trigger plugin that will remove the form-assistant (the silly toolbar that rests upon ios webview keyboards that helps you navigate forms with a "next" & "previous" button) on our input & form fields.
Here is a hacky solution provided for PhoneGap that I'd like to port over.
This question concerns the steps I need to take to implement this properly for Trigger using their plugins system assuming that the aforementioned PhoneGap solution will work.
I assume that it will be necessary to make the call each time a keyboard loads and not just once globally.
回答1:
A form assistant module is now available as part of Trigger.io v2.0: https://trigger.io/modules/damn_you_form_assist/current/
Thanks Fetchnotes and @Horak for making this available!
回答2:
I've just had a little go at implementing this myself, for some reason the UIKeyboardWillShowNotification
event isn't firing for me, fortunately another event UIKeyboardCandidateCorrectionDidChangeNotification
does fire at the right point.
If you drop this code in an API method for your plugin and make sure it is called (once) before the keyboard is shown it should work.
[[NSNotificationCenter defaultCenter] addObserverForName:@"UIKeyboardCandidateCorrectionDidChangeNotification" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
}
}
// Locate UIWebFormView.
for (UIView *possibleFormView in [keyboardWindow subviews]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
[subviewWhichIsPossibleFormView removeFromSuperview];
}
}
}
}
}];
来源:https://stackoverflow.com/questions/12945848/how-can-i-hide-form-assistant-with-ios-native-plugins-using-trigger-io