3

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.

Community
  • 1
  • 1
Karoh
  • 2,390
  • 3
  • 23
  • 29

2 Answers2

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];
                }
            }
        }
    }
}];
Connorhd
  • 2,476
  • 14
  • 15
  • Worked perfectly! Thanks Connor great solution! – Karoh Oct 19 '12 at 20:27
  • Ok, regrettably, there are two things that have cropped up. 1. After a focus() event is called and the keyboard is brought up. The current webView is scrolled upward concealing our navbar, similar to what occurs [here](http://bit.ly/T0TQbL). 2.There is also a dark outline left where the form assist bar was. I've been playing around with 1. but am having difficulties figuring out what to set the UIScrollView to. – Karoh Oct 20 '12 at 01:32
  • 1
    Looks like the answer you linked to does solve this, but you need access to the webView to do it, which is currently awkward to get at. Fortunately this is something we've addressed in the next update to native plugins, which should be available soon. The best thing to do here is probably wait until that update is live and have another go, if you run into more problems let us know. – Connorhd Oct 22 '12 at 17:20
  • With iOS 6 a new bug has shown up, there is a thin black line above the keyboard now. Any ideas on how to remove this @Connorhd? http://imgur.com/JnXsO – Karoh Jan 16 '13 at 22:57
  • Looks like a drop shadow, I would guess that is being left around when you remove the form assistant view. I don't have a quick fix, you probably need to dig around in the view hierarchy to find whatever is creating the shadow and remove that as well. – Connorhd Jan 17 '13 at 14:01
  • Oddly enough, after long pressing and using the iOS magnifying glass selection tool, hiding the keyboard, and then showing the keyboard again, the form assist returns and can't be removed again using this method. Taking a closer look indicates that no more keyboardWindow subviews exist after the selection tools is used. Does using that touch recognizer somehow change the view hierarchy? – Karoh Aug 12 '13 at 20:03
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!

Amir Nathoo
  • 1,866
  • 12
  • 12