Objective c Javascript将字符串返回到目标c

Objective c Javascript将字符串返回到目标c,objective-c,uiwebview,Objective C,Uiwebview,我有一个webview,我想从webview HTML表单捕获一个输入。我已经试过了,但是我找不到人能帮我吗 这是我的webview代码 // Init Web View UIWebView *webView; webView = [[UIWebView alloc] initWithFrame:boundsRect]; webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewA

我有一个webview,我想从webview HTML表单捕获一个输入。我已经试过了,但是我找不到人能帮我吗

这是我的webview代码

        // Init Web View
    UIWebView *webView;
    webView = [[UIWebView alloc] initWithFrame:boundsRect];
    webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    webView.scalesPageToFit = YES;
    webView.contentMode = UIViewContentModeCenter;
    webView.multipleTouchEnabled = NO;
    webView.userInteractionEnabled = YES;
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
    [self addSubview:webView];
    [webView release];
    return self;
为了从webView中获取值,我使用了以下代码

NSString* value = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('text').value"]‌​; 
NSLog(@"got: %@",value); 

你可以看看phonegap是如何解决这个问题的。

你试过什么?您的代码中没有任何内容建议您进行任何尝试。我尝试了以下操作:NSString*value=[webView stringByEvaluatingJavaScriptFromString:@“document.getElementById('text')。value”];NSLog(@“got:%@”,值);问题是
-stringByEvaluatingJavaScriptFromString:
返回nil?是的,在按下HTML按钮后,我不会返回任何要执行的内容请参见: