I have an UIWebView
with an <input type="text"/>
html element in it.
I want to focus the input element in the html and show the keyboard on the iPhone programmatically, without tapping the screen.
I've tried the following:
[webView becomeFirstresponder]
(returns NO)firstResponder
(returns NO)UIWebView
to return YES to canBecomeFirstResponder
: (nothing happens)I'm trying to find the solution since yesterday but I couldn't find it. Please help.
In iOS6 or above, you have to set keyboardDisplayRequiresUserAction
to NO
first:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
webView.keyboardDisplayRequiresUserAction = NO;
[webView stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"theElementId\").setFocus();"];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With