1

For an app I am working on I want a custom keyboard to come up when you tap on an input field in a UIWebview, for example for UITextView i use this code :

 myText.text = [myText.text stringByAppendingString:@"a"];

but i don't know how can i fill a text field in UIWebVIew Any help would be very much appreciated; thanks!

Douwe Maan
  • 6,888
  • 2
  • 34
  • 35
iOS.Lover
  • 5,923
  • 21
  • 90
  • 162

4 Answers4

1

I don't think it's possible to use a custom keyboard for a text field within a UIWebView.

Douwe Maan
  • 6,888
  • 2
  • 34
  • 35
  • so what did he do ?: he use custom keyboard http://itunes.apple.com/us/app/arabic-browser-for-ipad/id367397633?mt=8 – iOS.Lover May 01 '10 at 09:58
  • Because what he did is use a custom keyboard for the URL address bar, which is just a `UITextView` that Cocoa Touch can talk to. But as far as I'm aware, it isn't possible to hijack the keyboard for text fields within the `UIWebView`... – Douwe Maan May 01 '10 at 10:05
  • If my answer has answered your question, I'd be happy if you accepted it by ticking it ;) – Douwe Maan May 01 '10 at 12:06
  • what about this article? the answerer suggest to use a UITextField as a "Media". http://stackoverflow.com/questions/19961369/how-the-default-keyboard-comes-up-when-user-taps-in-uiwebview – syoleen Dec 19 '14 at 00:30
1

There is bidirectional communication with the UIWebView, but it is a little convoluted.

You can use stringByEvaluatingJavaScriptFromString to execute any javascript in the context of the web page. That can be used to send data to the web page, modify forms, or poll for data and events.

You can use webView:shouldStartLoadWithRequest:navigationType: to receive notifications from the web view. Define a custom scheme like myapp: and handle all such requests returning NO from shouldStart. You can use ajax style calls to trigger the notifications, although the actual ajax call will always fail because you are returning NO.

If you want to have a custom keyboard show up, you must send a notification to the host application via your custom scheme, display a UITextView over the web view, then send the results back via javascript.

At least, that is the documented way to do it.

drawnonward
  • 53,459
  • 16
  • 107
  • 112
  • That's only necessary if you are trying to fill in a web page. I get the impression that the OP wants to use a UIWebView as a "better" UITextView - in which case you can feed it using loadHTMLString:. – Paul Lynch May 01 '10 at 10:42
  • 1
    thnak you but i think it's complex for me !:) – iOS.Lover May 01 '10 at 11:39
0

I spent too much time investigating that.

Blur the text inputs using JavaScript or jQuery. Use on screen keyboard like any UIjquery plugin

Now you have to take a look at this nice keyboard and learn how to integrate it into you web pages.

http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-keyboard-with-css-and-jquery/

One limitation. It works only for your pages unless you hijack the page when it is done loading and attaché your keyboard and blur all text inputs when they get highlighted or focused.

Mahmoud Fayez
  • 3,398
  • 2
  • 19
  • 36
0

Check dcorbatta's answer in this article Custom Keyboard in UIWebView

He suggest to use a UITextField as a "media" when you detect keyboard coming up inside a UIWebView. Thus, you can use whatever Keyboard type you want on the UITextField. After users taps something, copy the text in UITextField the media via JavaScript ActiveDocument.

Community
  • 1
  • 1
syoleen
  • 281
  • 2
  • 10