I have a very simple page which is loaded inside the UIWebView using the following code:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL *url = [NSURL URLWithString:@"http://www.highoncoding.com/home/test"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
}
And I am trying to focus on the TextBox "txtName" using the following code:
- (void)webViewDidFinishLoad:(UIWebView *)wv
{
NSLog(@"webViewDidFinished");
[wv stringByEvaluatingJavaScriptFromString:@"if(document.getElementById('txtName') != null) { document.getElementById('txtName').focus() }"];
}
Although it does find the TextBox but it never focus on the TextBox and the keyboard never pops up.