Calling Javascript using UIWebView

前端 未结 2 876
野趣味
野趣味 2020-11-27 18:08

I am trying to call a javascript in a html page using the function -

View did load function
{

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDo         


        
2条回答
  •  孤独总比滥情好
    2020-11-27 19:05

    Simple: You try to execute the JS function from Objective-C before the page even has been loaded.

    Implement the UIWebView's delegate method webViewDidFinishLoad: in your UIViewController and in there you call [graphView stringByEvaluatingJavaScriptFromString:@"methodName()"]; to make sure the function gets called after the page has been loaded.

提交回复
热议问题