views:

325

answers:

2

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!

+1  A: 

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

Douwe Maan
so what did he do ?: he use custom keyboard http://itunes.apple.com/us/app/arabic-browser-for-ipad/id367397633?mt=8
Mc.Lover
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
thank you ! yes ur right
Mc.Lover
If my answer has answered your question, I'd be happy if you accepted it by ticking it ;)
Douwe Maan
A: 

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
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
thnak you but i think it's complex for me !:)
Mc.Lover