1

我有一个非常简单的页面,它使用以下代码在 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];

}

我正在尝试使用以下代码专注于文本框“txtName”:

- (void)webViewDidFinishLoad:(UIWebView *)wv
{
    NSLog(@"webViewDidFinished");

    [wv stringByEvaluatingJavaScriptFromString:@"if(document.getElementById('txtName') != null) { document.getElementById('txtName').focus() }"];
}

虽然它确实找到了 TextBox,但它从不关注 TextBox,键盘也永远不会弹出。

4

0 回答 0