Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

html - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...