我正在尝试使用该函数在 html 页面中调用 javascript -
View did load function
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writablePath = [documentsDirectory stringByAppendingPathComponent:@"BasicGraph.html"];
NSURL *urlStr = [NSURL fileURLWithPath:writablePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *myPathInfo = [[NSBundle mainBundle] pathForResource:@"BasicGraph" ofType:@"html"];
[fileManager copyItemAtPath:myPathInfo toPath:writablePath error:NULL];
[graphView loadRequest:[NSURLRequest requestWithURL:urlStr]];
}
- (void) webViewDidFinishLoad:(UIWebView *)webView
{
[graphView stringByEvaluatingJavaScriptFromString:@"methodName()"];
}
这是html页面上的javascript -
<script>
function methodName()
{
// code to draw graph
}
但是,该函数methodName()
没有被调用,但在 window.onload = function () 之后一切正常..
我正在尝试将RGraphs集成到我的应用程序Basic.html
中,并且是编写 javascripts 的 html 页面。
如果有人可以帮助我解决这个问题,那就太好了。