1

Here is my context: I have a webview with a simple form on it (one input type="text"), and I would like two things: - when I press the Go button the keyboard should disappear - I don't want the prev/next done toolbar on the keyboard

I tried a lot of solutions found here and there, (like this one iPhone keyboard in UIWebView does not go away nothing working at all :/

Any pointers/input I could try?

Thanks by advance!

Community
  • 1
  • 1
Pasta
  • 1,750
  • 2
  • 14
  • 25

2 Answers2

4

For removing the keyboard, if you know the ID of the TextField you could try adding your class as the WebView Delegate and injecting some Javascript to hide the Keyboard like so (The Class where you set up the Delegate must have the UIWebViewDelegate Protocol in the interface declaration):

// Where you set up your WebView, add a class as a Delegate (self in this case)
[webView setDelegate:self];

Now you need to have the Delegate Method which is called when a new page is requested

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('myInput').blur();"];
    return YES;
}
Suhail Patel
  • 13,644
  • 2
  • 44
  • 49
  • 2
    Allright, this was helpfull, cause it lead me to the solution : http://stackoverflow.com/questions/4179445/knowing-when-ajax-has-loaded-in-uiwebview Do you now have any idea how to remove the prev/nest done bar at the top of the keyboard? – Pasta Jul 17 '11 at 16:01
  • @Pasta - Please submit that as a new question. I'd search for it first... it seems likely that someone has already asked that. – gilly3 Jul 22 '11 at 17:28
-1
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    [self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[textField text]]]];

    return YES;
}

CHECK THIS!!!

bharath
  • 14,283
  • 16
  • 57
  • 95