Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide Form Assistant with iOS native plugins using Trigger.IO?

Tags:

trigger.io

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.

like image 711
Karoh Avatar asked Dec 05 '25 19:12

Karoh


1 Answers

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];
                }
            }
        }
    }
}];
like image 109
Connorhd Avatar answered Dec 07 '25 22:12

Connorhd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!