次のように、View ControllerにUIWebViewが埋め込まれています。
Web ビュー ( ) へのアウトレットがあり、これを使用して_graphTotal
コンテンツを正常にロードできます。test.html
[_graphTotal loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"]isDirectory:NO]]];
私は今、データを Web ビューに渡そうとしていますが、運がありませんでした。を追加しましたが、これが<UIWebViewDelegate>
私が試していることです:
NSString *userName = [_graphTotal stringByEvaluatingJavaScriptFromString:@"testFunction()"];
NSLog(@"Web response: %@",userName);
そして、ここtest.html
に私のプロジェクトの内容があります:
<html>
<head></head>
<body>
Testing...
<script type="text/javascript">
function testFunction() {
alert("made it!");
return "hi!";
}
</script>
</body>
</html>
webView に「Testing...」と表示されますが、アラートも返された「hi!」も表示されません。ストリング。
私が間違っていることは何か分かりますか?