Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove form assistant from keyboard in iPhone standalone web app

Is it possible to remove the form assistant from the iPhone popup keyboard in a standalone web app? I know the general consensus is that it's not possible in Mobile Safari, but a standalone app runs in a UIWebView, and functions differently in several ways (example), so I'm hoping this might be possible.

You can see it here right above the keyboard:

enter image description here

The Previous and Next buttons cycle between <form> inputs. But I have a single <input> element, so they are disabled. The Done button hides the keyboard, but since I have a height-flexible <ul> (that takes up the space between the keyboard and the <input>), and I have nothing else on this page, it serves no purpose.

On a tiny screen, and with almost half the screen taken up by the keyboard, the 44 pixels that make up this toolbar are a huge waste of space (an entire <li>'s worth).

Native iOS apps can remove it, so I know it's at least possible on the phone, I've just not discovered a way to do it in a web app. This is from the Facebook app and the page is very similar to mine:

enter image description here

I've tried using an <input> not wrapped in a <form> and also using a contenteditable <div>, but the results were the same. There are several custom -webkit- styles to control various aspects of the web app interface, but they are poorly documented, and a search turned up nothing on this.

Any way to remove the form assistant in a web app?

like image 444
ThinkingStiff Avatar asked Oct 26 '11 15:10

ThinkingStiff


2 Answers

If you app is a web app wrapped in a native Objetive-C app this is possible by manipulating Keyboard views.

first, register to receive the keyboardDidShow notification:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];

this will call the following method when keyboard shows up:

-(void)keyboardDidShow:(NSNotification*)notif
{
    NSArray *array = [[UIApplication sharedApplication] windows];

    for (UIWindow* wind in array) {
        for (UIView* currView in wind.subviews) {
            if ([[currView description] hasPrefix:@"<UIPeripheralHostView"]) {
                for (UIView* perView in currView.subviews) {
                    if ([[perView description] hasPrefix:@"<UIWebFormAccessory"]) {
                        [perView setHidden:YES];
                    }
                }

            }
        }
    }
}

this method goes over the views on screen looking for the form assistant and hiding it.

NOTE: Apple probably won't reject this, as i've seen it being used by Facebook etc, but this technique might break in upcoming iOS releases.

like image 138
Jorge Cohen Avatar answered Oct 05 '22 23:10

Jorge Cohen


All signs point to this not being possible, including several questions here.

like image 24
seth.miller Avatar answered Oct 05 '22 23:10

seth.miller