我有一个非常简单的页面,它使用以下代码加载到UIWebView中:
- (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];
}
我正在尝试使用以下代码专注于TextBox“txtName”:
- (void)webViewDidFinishLoad:(UIWebView *)wv
{
NSLog(@"webViewDidFinished");
[wv stringByEvaluatingJavaScriptFromString:@"if(document.getElementById('txtName') != null) { document.getElementById('txtName').focus() }"];
}
虽然它确实找到了TextBox,但它从不关注TextBox,键盘也不会弹出。